diff options
Diffstat (limited to 'docs/sources/use')
-rw-r--r-- | docs/sources/use/ambassador_pattern_linking.rst | 28 | ||||
-rw-r--r-- | docs/sources/use/basics.rst | 4 | ||||
-rw-r--r-- | docs/sources/use/chef.rst | 95 | ||||
-rw-r--r-- | docs/sources/use/host_integration.rst | 5 | ||||
-rw-r--r-- | docs/sources/use/index.rst | 1 | ||||
-rw-r--r-- | docs/sources/use/networking.rst | 4 | ||||
-rw-r--r-- | docs/sources/use/port_redirection.rst | 6 | ||||
-rw-r--r-- | docs/sources/use/working_with_links_names.rst | 26 | ||||
-rw-r--r-- | docs/sources/use/working_with_volumes.rst | 22 | ||||
-rw-r--r-- | docs/sources/use/workingwithrepository.rst | 2 |
10 files changed, 147 insertions, 46 deletions
diff --git a/docs/sources/use/ambassador_pattern_linking.rst b/docs/sources/use/ambassador_pattern_linking.rst index e7cdbd7c96..bbd5816768 100644 --- a/docs/sources/use/ambassador_pattern_linking.rst +++ b/docs/sources/use/ambassador_pattern_linking.rst @@ -43,26 +43,26 @@ Start actual redis server on one Docker host .. code-block:: bash - big-server $ docker run -d -name redis crosbymichael/redis + big-server $ docker run -d --name redis crosbymichael/redis Then add an ambassador linked to the redis server, mapping a port to the outside world .. code-block:: bash - big-server $ docker run -d -link redis:redis -name redis_ambassador -p 6379:6379 svendowideit/ambassador + big-server $ docker run -d --link redis:redis --name redis_ambassador -p 6379:6379 svendowideit/ambassador On the other host, you can set up another ambassador setting environment variables for each remote port we want to proxy to the ``big-server`` .. code-block:: bash - client-server $ docker run -d -name redis_ambassador -expose 6379 -e REDIS_PORT_6379_TCP=tcp://192.168.1.52:6379 svendowideit/ambassador + client-server $ docker run -d --name redis_ambassador --expose 6379 -e REDIS_PORT_6379_TCP=tcp://192.168.1.52:6379 svendowideit/ambassador Then on the ``client-server`` host, you can use a redis client container to talk to the remote redis server, just by linking to the local redis ambassador. .. code-block:: bash - client-server $ docker run -i -t -rm -link redis_ambassador:redis relateiq/redis-cli + client-server $ docker run -i -t --rm --link redis_ambassador:redis relateiq/redis-cli redis 172.17.0.160:6379> ping PONG @@ -79,19 +79,19 @@ On the docker host (192.168.1.52) that redis will run on: .. code-block:: bash # start actual redis server - $ docker run -d -name redis crosbymichael/redis + $ docker run -d --name redis crosbymichael/redis # get a redis-cli container for connection testing $ docker pull relateiq/redis-cli # test the redis server by talking to it directly - $ docker run -t -i -rm -link redis:redis relateiq/redis-cli + $ docker run -t -i --rm --link redis:redis relateiq/redis-cli redis 172.17.0.136:6379> ping PONG ^D # add redis ambassador - $ docker run -t -i -link redis:redis -name redis_ambassador -p 6379:6379 busybox sh + $ docker run -t -i --link redis:redis --name redis_ambassador -p 6379:6379 busybox sh in the redis_ambassador container, you can see the linked redis containers's env @@ -119,7 +119,7 @@ This environment is used by the ambassador socat script to expose redis to the w $ docker rm redis_ambassador $ sudo ./contrib/mkimage-unittest.sh - $ docker run -t -i -link redis:redis -name redis_ambassador -p 6379:6379 docker-ut sh + $ docker run -t -i --link redis:redis --name redis_ambassador -p 6379:6379 docker-ut sh $ socat TCP4-LISTEN:6379,fork,reuseaddr TCP4:172.17.0.136:6379 @@ -127,7 +127,7 @@ then ping the redis server via the ambassador .. code-block::bash - $ docker run -i -t -rm -link redis_ambassador:redis relateiq/redis-cli + $ docker run -i -t --rm --link redis_ambassador:redis relateiq/redis-cli redis 172.17.0.160:6379> ping PONG @@ -136,7 +136,7 @@ Now goto a different server .. code-block:: bash $ sudo ./contrib/mkimage-unittest.sh - $ docker run -t -i -expose 6379 -name redis_ambassador docker-ut sh + $ docker run -t -i --expose 6379 --name redis_ambassador docker-ut sh $ socat TCP4-LISTEN:6379,fork,reuseaddr TCP4:192.168.1.52:6379 @@ -145,7 +145,7 @@ and get the redis-cli image so we can talk over the ambassador bridge .. code-block:: bash $ docker pull relateiq/redis-cli - $ docker run -i -t -rm -link redis_ambassador:redis relateiq/redis-cli + $ docker run -i -t --rm --link redis_ambassador:redis relateiq/redis-cli redis 172.17.0.160:6379> ping PONG @@ -157,7 +157,7 @@ When you start the container, it uses a small ``sed`` script to parse out the (p link environment variables to set up the port forwarding. On the remote host, you need to set the variable using the ``-e`` command line option. -``-expose 1234 -e REDIS_PORT_1234_TCP=tcp://192.168.1.52:6379`` will forward the +``--expose 1234 -e REDIS_PORT_1234_TCP=tcp://192.168.1.52:6379`` will forward the local ``1234`` port to the remote IP and port - in this case ``192.168.1.52:6379``. @@ -171,9 +171,9 @@ local ``1234`` port to the remote IP and port - in this case ``192.168.1.52:6379 # docker build -t SvenDowideit/ambassador . # docker tag SvenDowideit/ambassador ambassador # then to run it (on the host that has the real backend on it) - # docker run -t -i -link redis:redis -name redis_ambassador -p 6379:6379 ambassador + # docker run -t -i --link redis:redis --name redis_ambassador -p 6379:6379 ambassador # on the remote host, you can set up another ambassador - # docker run -t -i -name redis_ambassador -expose 6379 sh + # docker run -t -i --name redis_ambassador --expose 6379 sh FROM docker-ut MAINTAINER SvenDowideit@home.org.au diff --git a/docs/sources/use/basics.rst b/docs/sources/use/basics.rst index 24c22bba39..4164e706f7 100644 --- a/docs/sources/use/basics.rst +++ b/docs/sources/use/basics.rst @@ -39,7 +39,9 @@ Repository to a local image cache. 12 character hash ``539c0211cd76: Download complete`` which is the short form of the image ID. These short image IDs are the first 12 characters of the full image ID - which can be found using ``docker - inspect`` or ``docker images -notrunc=true`` + inspect`` or ``docker images --no-trunc=true`` + + **If you're using OS X** then you shouldn't use ``sudo`` Running an interactive shell ---------------------------- diff --git a/docs/sources/use/chef.rst b/docs/sources/use/chef.rst new file mode 100644 index 0000000000..919eba7a8f --- /dev/null +++ b/docs/sources/use/chef.rst @@ -0,0 +1,95 @@ +:title: Chef Usage +:description: Installation and using Docker via Chef +:keywords: chef, installation, usage, docker, documentation + +.. _install_using_chef: + +Using Chef +============= + +.. note:: + + Please note this is a community contributed installation path. The + only 'official' installation is using the :ref:`ubuntu_linux` + installation path. This version may sometimes be out of date. + +Requirements +------------ + +To use this guide you'll need a working installation of +`Chef <http://www.getchef.com/>`_. This cookbook supports a variety of +operating systems. + +Installation +------------ + +The cookbook is available on the `Chef Community Site +<community.opscode.com/cookbooks/docker>`_ and can be installed +using your favorite cookbook dependency manager. + +The source can be found on `GitHub +<https://github.com/bflad/chef-docker>`_. + +Usage +----- + +The cookbook provides recipes for installing Docker, configuring init +for Docker, and resources for managing images and containers. +It supports almost all Docker functionality. + +Installation +~~~~~~~~~~~~ + +.. code-block:: ruby + + include_recipe 'docker' + +Images +~~~~~~ + +The next step is to pull a Docker image. For this, we have a resource: + +.. code-block:: ruby + + docker_image 'samalba/docker-registry' + +This is equivalent to running: + +.. code-block:: bash + + docker pull samalba/docker-registry + +There are attributes available to control how long the cookbook +will allow for downloading (5 minute default). + +To remove images you no longer need: + +.. code-block:: ruby + + docker_image 'samalba/docker-registry' do + action :remove + end + +Containers +~~~~~~~~~~ + +Now you have an image where you can run commands within a container +managed by Docker. + +.. code-block:: ruby + + docker_container 'samalba/docker-registry' do + detach true + port '5000:5000' + env 'SETTINGS_FLAVOR=local' + volume '/mnt/docker:/docker-storage' + end + +This is equivalent to running the following command, but under upstart: + +.. code-block:: bash + + docker run --detach=true --publish='5000:5000' --env='SETTINGS_FLAVOR=local' --volume='/mnt/docker:/docker-storage' samalba/docker-registry + +The resources will accept a single string or an array of values +for any docker flags that allow multiple values. diff --git a/docs/sources/use/host_integration.rst b/docs/sources/use/host_integration.rst index ed341cd4bc..cb920a5908 100644 --- a/docs/sources/use/host_integration.rst +++ b/docs/sources/use/host_integration.rst @@ -43,11 +43,6 @@ into it: stop on runlevel [!2345] respawn script - # Wait for docker to finish starting up first. - FILE=/var/run/docker.sock - while [ ! -e $FILE ] ; do - inotifywait -t 2 -e create $(dirname $FILE) - done /usr/bin/docker start -a redis_server end script diff --git a/docs/sources/use/index.rst b/docs/sources/use/index.rst index c1b7691cca..dcf6289b41 100644 --- a/docs/sources/use/index.rst +++ b/docs/sources/use/index.rst @@ -20,4 +20,5 @@ Contents: working_with_volumes working_with_links_names ambassador_pattern_linking + chef puppet diff --git a/docs/sources/use/networking.rst b/docs/sources/use/networking.rst index c00c608550..59c63ed674 100644 --- a/docs/sources/use/networking.rst +++ b/docs/sources/use/networking.rst @@ -121,8 +121,8 @@ Container intercommunication The value of the Docker daemon's ``icc`` parameter determines whether containers can communicate with each other over the bridge network. -- The default, ``-icc=true`` allows containers to communicate with each other. -- ``-icc=false`` means containers are isolated from each other. +- The default, ``--icc=true`` allows containers to communicate with each other. +- ``--icc=false`` means containers are isolated from each other. Docker uses ``iptables`` under the hood to either accept or drop communication between containers. diff --git a/docs/sources/use/port_redirection.rst b/docs/sources/use/port_redirection.rst index 38d6b98841..cf5c2100a9 100644 --- a/docs/sources/use/port_redirection.rst +++ b/docs/sources/use/port_redirection.rst @@ -114,21 +114,21 @@ exposure, is possible because ``client`` is started after ``server`` has been started. Here is a full example. On ``server``, the port of interest is -exposed. The exposure is done either through the ``-expose`` parameter +exposed. The exposure is done either through the ``--expose`` parameter to the ``docker run`` command, or the ``EXPOSE`` build command in a Dockerfile: .. code-block:: bash # Expose port 80 - docker run -expose 80 --name server <image> <cmd> + docker run --expose 80 --name server <image> <cmd> The ``client`` then links to the ``server``: .. code-block:: bash # Link - docker run -name client -link server:linked-server <image> <cmd> + docker run --name client --link server:linked-server <image> <cmd> ``client`` locally refers to ``server`` as ``linked-server``. The following environment variables, among others, are available on diff --git a/docs/sources/use/working_with_links_names.rst b/docs/sources/use/working_with_links_names.rst index 1b0e9f6914..4acb6079c1 100644 --- a/docs/sources/use/working_with_links_names.rst +++ b/docs/sources/use/working_with_links_names.rst @@ -19,14 +19,14 @@ Container Naming .. versionadded:: v0.6.5 -You can now name your container by using the ``-name`` flag. If no +You can now name your container by using the ``--name`` flag. If no name is provided, Docker will automatically generate a name. You can see this name using the ``docker ps`` command. .. code-block:: bash - # format is "sudo docker run -name <container_name> <image_name> <command>" - $ sudo docker run -name test ubuntu /bin/bash + # format is "sudo docker run --name <container_name> <image_name> <command>" + $ sudo docker run --name test ubuntu /bin/bash # the flag "-a" Show all containers. Only running containers are shown by default. $ sudo docker ps -a @@ -41,9 +41,9 @@ Links: service discovery for docker .. versionadded:: v0.6.5 Links allow containers to discover and securely communicate with each -other by using the flag ``-link name:alias``. Inter-container +other by using the flag ``--link name:alias``. Inter-container communication can be disabled with the daemon flag -``-icc=false``. With this flag set to ``false``, Container A cannot +``--icc=false``. With this flag set to ``false``, Container A cannot access Container B unless explicitly allowed via a link. This is a huge win for securing your containers. When two containers are linked together Docker creates a parent child relationship between the @@ -63,7 +63,7 @@ based on that image and run it as a daemon. .. code-block:: bash - $ sudo docker run -d -name redis crosbymichael/redis + $ sudo docker run -d --name redis crosbymichael/redis We can issue all the commands that you would expect using the name ``redis``; start, stop, attach, using the name for our container. The @@ -77,9 +77,9 @@ we need to establish a link. .. code-block:: bash - $ sudo docker run -t -i -link redis:db -name webapp ubuntu bash + $ sudo docker run -t -i --link redis:db --name webapp ubuntu bash -When you specified ``-link redis:db`` you are telling Docker to link +When you specified ``--link redis:db`` you are telling Docker to link the container named ``redis`` into this new container with the alias ``db``. Environment variables are prefixed with the alias so that the parent container can access network and environment information from @@ -112,8 +112,16 @@ Accessing the network information along with the environment of the child container allows us to easily connect to the Redis service on the specific IP and port in the environment. +.. note:: + These Environment variables are only set for the first process in + the container. Similarly, some daemons (such as ``sshd``) will + scrub them when spawning shells for connection. + + You can work around this by storing the initial ``env`` in a file, + or looking at ``/proc/1/environ``. + Running ``docker ps`` shows the 2 containers, and the ``webapp/db`` -alias name for the redis container. +alias name for the Redis container. .. code-block:: bash diff --git a/docs/sources/use/working_with_volumes.rst b/docs/sources/use/working_with_volumes.rst index 755be009e3..d2f035dc84 100644 --- a/docs/sources/use/working_with_volumes.rst +++ b/docs/sources/use/working_with_volumes.rst @@ -42,14 +42,14 @@ two new volumes:: This command will create the new container with two new volumes that exits instantly (``true`` is pretty much the smallest, simplest program that you can run). Once created you can mount its volumes in any other -container using the ``-volumes-from`` option; irrespective of whether the +container using the ``--volumes-from`` option; irrespective of whether the container is running or not. Or, you can use the VOLUME instruction in a Dockerfile to add one or more new volumes to any container created from that image:: # BUILD-USING: docker build -t data . - # RUN-USING: docker run -name DATA data + # RUN-USING: docker run --name DATA data FROM busybox VOLUME ["/var/volume1", "/var/volume2"] CMD ["/bin/true"] @@ -63,19 +63,19 @@ Data Volume Container, and then to mount the data from it. Create a named container with volumes to share (``/var/volume1`` and ``/var/volume2``):: - $ docker run -v /var/volume1 -v /var/volume2 -name DATA busybox true + $ docker run -v /var/volume1 -v /var/volume2 --name DATA busybox true Then mount those data volumes into your application containers:: - $ docker run -t -i -rm -volumes-from DATA -name client1 ubuntu bash + $ docker run -t -i --rm --volumes-from DATA --name client1 ubuntu bash -You can use multiple ``-volumes-from`` parameters to bring together multiple +You can use multiple ``--volumes-from`` parameters to bring together multiple data volumes from multiple containers. Interestingly, you can mount the volumes that came from the ``DATA`` container in yet another container via the ``client1`` middleman container:: - $ docker run -t -i -rm -volumes-from client1 -name client2 ubuntu bash + $ docker run -t -i --rm --volumes-from client1 --name client2 ubuntu bash This allows you to abstract the actual data source from users of that data, similar to :ref:`ambassador_pattern_linking <ambassador_pattern_linking>`. @@ -129,9 +129,9 @@ because they are external to images. Instead you can use ``--volumes-from`` to start a new container that can access the data-container's volume. For example:: - $ sudo docker run -rm --volumes-from DATA -v $(pwd):/backup busybox tar cvf /backup/backup.tar /data + $ sudo docker run --rm --volumes-from DATA -v $(pwd):/backup busybox tar cvf /backup/backup.tar /data -* ``-rm`` - remove the container when it exits +* ``--rm`` - remove the container when it exits * ``--volumes-from DATA`` - attach to the volumes shared by the ``DATA`` container * ``-v $(pwd):/backup`` - bind mount the current directory into the container; to write the tar file to * ``busybox`` - a small simpler image - good for quick maintenance @@ -140,13 +140,13 @@ data-container's volume. For example:: Then to restore to the same container, or another that you've made elsewhere:: # create a new data container - $ sudo docker run -v /data -name DATA2 busybox true + $ sudo docker run -v /data --name DATA2 busybox true # untar the backup files into the new container's data volume - $ sudo docker run -rm --volumes-from DATA2 -v $(pwd):/backup busybox tar xvf /backup/backup.tar + $ sudo docker run --rm --volumes-from DATA2 -v $(pwd):/backup busybox tar xvf /backup/backup.tar data/ data/sven.txt # compare to the original container - $ sudo docker run -rm --volumes-from DATA -v `pwd`:/backup busybox ls /data + $ sudo docker run --rm --volumes-from DATA -v `pwd`:/backup busybox ls /data sven.txt diff --git a/docs/sources/use/workingwithrepository.rst b/docs/sources/use/workingwithrepository.rst index cbde932cde..c126361f8c 100644 --- a/docs/sources/use/workingwithrepository.rst +++ b/docs/sources/use/workingwithrepository.rst @@ -74,7 +74,7 @@ name or description: Search the docker index for images - -notrunc=false: Don't truncate output + --no-trunc=false: Don't truncate output $ sudo docker search centos Found 25 results matching your query ("centos") NAME DESCRIPTION |