diff --git a/toolbox/Dockerfile b/toolbox/Dockerfile index aedc2359c..83aed97b2 100644 --- a/toolbox/Dockerfile +++ b/toolbox/Dockerfile @@ -29,4 +29,5 @@ RUN apt-get update && \ vim \ && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -CMD ["/bin/bash"] \ No newline at end of file +COPY entrypoint.sh /toolbox/ +ENTRYPOINT [ "/toolbox/entrypoint.sh" ] \ No newline at end of file diff --git a/toolbox/README.md b/toolbox/README.md index 209c17247..e92e7ff54 100644 --- a/toolbox/README.md +++ b/toolbox/README.md @@ -16,13 +16,24 @@ toolbox ``` ### Ceph Tools -To use the ceph tools from a rook host, launch the toolbox and run the following command: +To use the ceph tools from a rook host, launch the toolbox with the following options: ``` -toolbox --bind=/var/lib/rook:/var/lib/rook -ROOK_CONFIG=`find /var/lib/rook -regex '.*mon[0-9]+/.*\.config' | head -1` +toolbox --bind=/var/lib/rook:/var/lib/rook /toolbox/entrypoint.sh ``` Then you can run `ceph` and `rados` commands like usual: ``` -ceph -c ${ROOK_CONFIG} df -rados -c ${ROOK_CONFIG} df +ceph df +rados df +``` + +## Other Linux Distros +The rook toolbox container can simply be run directly with `docker` on other Linux distros: +``` +docker run -it quay.io/rook/toolbox +``` + +### Ceph Tools +To run ceph tools such as `ceph` and `rados`, run the container with the following options: +``` +docker run -it --network=host -v /var/lib/rook:/var/lib/rook quay.io/rook/toolbox ``` \ No newline at end of file diff --git a/toolbox/entrypoint.sh b/toolbox/entrypoint.sh new file mode 100755 index 000000000..396600918 --- /dev/null +++ b/toolbox/entrypoint.sh @@ -0,0 +1,33 @@ +#!/bin/bash -e + +# Copyright 2016 The Rook Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARGS="$@" +if [ $# -eq 0 ]; then + ARGS=/bin/bash +fi + +# find one of rook's ceph config files and copy it to the default location so ceph/rados tools +# can be used without specifying a config file path +ROOK_DIR="/var/lib/rook" +if [[ -d ${ROOK_DIR} ]]; then + ROOK_CONFIG=`find ${ROOK_DIR} -regex '.*mon[0-9]+/.*\.config' | head -1` + if [[ ! -z ${ROOK_CONFIG} ]]; then + mkdir -p /etc/ceph + cp ${ROOK_CONFIG} /etc/ceph/ceph.conf + fi +fi + +exec ${ARGS} \ No newline at end of file