| ... | ... |
@@ -6,6 +6,21 @@ |
| 6 | 6 |
The basics |
| 7 | 7 |
============= |
| 8 | 8 |
|
| 9 |
+Starting Docker |
|
| 10 |
+--------------- |
|
| 11 |
+ |
|
| 12 |
+If you have used one of the quick install paths', Docker may have been installed with upstart, Ubuntu's |
|
| 13 |
+system for starting processes at boot time. You should be able to run ``docker help`` and get output. |
|
| 14 |
+ |
|
| 15 |
+If you get ``docker: command not found`` or something like ``/var/lib/docker/repositories: permission denied`` |
|
| 16 |
+you will need to specify the path to it and manually start it. |
|
| 17 |
+ |
|
| 18 |
+.. code-block:: bash |
|
| 19 |
+ |
|
| 20 |
+ # Run docker in daemon mode |
|
| 21 |
+ sudo <path to>/docker -d & |
|
| 22 |
+ |
|
| 23 |
+ |
|
| 9 | 24 |
Running an interactive shell |
| 10 | 25 |
---------------------------- |
| 11 | 26 |
|
| ... | ... |
@@ -24,9 +39,6 @@ Starting a long-running worker process |
| 24 | 24 |
|
| 25 | 25 |
.. code-block:: bash |
| 26 | 26 |
|
| 27 |
- # Run docker in daemon mode |
|
| 28 |
- (sudo docker -d || echo "Docker daemon already running") & |
|
| 29 |
- |
|
| 30 | 27 |
# Start a very useful long-running process |
| 31 | 28 |
JOB=$(docker run -d base /bin/sh -c "while true; do echo Hello world; sleep 1; done") |
| 32 | 29 |
|
| ... | ... |
@@ -56,33 +68,33 @@ Expose a service on a TCP port |
| 56 | 56 |
PORT=$(docker port $JOB 4444) |
| 57 | 57 |
|
| 58 | 58 |
# Connect to the public port via the host's public address |
| 59 |
+ # Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work. |
|
| 59 | 60 |
echo hello world | nc $(hostname) $PORT |
| 60 | 61 |
|
| 61 | 62 |
# Verify that the network connection worked |
| 62 | 63 |
echo "Daemon received: $(docker logs $JOB)" |
| 63 | 64 |
|
| 64 |
-Continue to the complete `Command Line Interface`_ |
|
| 65 | 65 |
|
| 66 |
-.. _Command Line Interface: ../commandline/cli.html |
|
| 66 |
+Committing (saving) an image |
|
| 67 |
+----------------------------- |
|
| 67 | 68 |
|
| 69 |
+Save your containers state to a container image, so the state can be re-used. |
|
| 68 | 70 |
|
| 69 |
-Committing an image |
|
| 71 |
+When you commit your container only the differences between the image the container was created from |
|
| 72 |
+and the current state of the container will be stored (as a diff). See which images you already have |
|
| 73 |
+using ``docker images`` |
|
| 70 | 74 |
|
| 71 |
-Committing your container to an (named) image is useful because this way it can be re-used. Compare it to creating |
|
| 72 |
-a virtual machine image. Except your containers will generally be shorted lived so saving (committing) the state of |
|
| 73 |
-it is more important. |
|
| 74 |
- |
|
| 75 |
-The state of a container can be saved at any time by running |
|
| 75 |
+.. code-block:: bash |
|
| 76 | 76 |
|
| 77 |
-:: |
|
| 77 |
+ # Commit your container to a new named image |
|
| 78 |
+ docker commit <container_id> <some_name> |
|
| 78 | 79 |
|
| 79 |
- docker commit <container_id> |
|
| 80 |
+ # List your containers |
|
| 81 |
+ docker images |
|
| 80 | 82 |
|
| 81 |
-However, it is probably more useful to commit it to a specific name |
|
| 83 |
+You now have a image state from which you can create new instances. |
|
| 82 | 84 |
|
| 83 |
-:: |
|
| 84 | 85 |
|
| 85 |
- docker commit <container_id> <your username>/some_name |
|
| 86 | 86 |
|
| 87 |
+Read more about :ref:`working_with_the_repository` or continue to the complete :ref:`cli` |
|
| 87 | 88 |
|
| ... | ... |
@@ -1,4 +1,4 @@ |
| 1 |
- |
|
| 1 |
+.. _working_with_the_repository: |
|
| 2 | 2 |
|
| 3 | 3 |
Working with the repository |
| 4 | 4 |
============================ |
| ... | ... |
@@ -8,7 +8,7 @@ Connecting to the repository |
| 8 | 8 |
|
| 9 | 9 |
You create a user on the central docker repository by running |
| 10 | 10 |
|
| 11 |
-:: |
|
| 11 |
+.. code-block:: bash |
|
| 12 | 12 |
|
| 13 | 13 |
docker login |
| 14 | 14 |
|
| ... | ... |
@@ -20,33 +20,23 @@ automatically log you in. |
| 20 | 20 |
Committing a container to a named image |
| 21 | 21 |
--------------------------------------- |
| 22 | 22 |
|
| 23 |
-Committing containers to named images is not only usefull when committing to the repository. But in order to commit to |
|
| 24 |
-the repository it is required to have an image with your namespace. |
|
| 25 |
- |
|
| 26 |
-The state of a container can be saved at any time by running |
|
| 27 |
- |
|
| 28 |
-:: |
|
| 23 |
+In order to commit to the repository it is required to have committed your container to an image with your namespace. |
|
| 29 | 24 |
|
| 30 |
- docker commit <container_id> |
|
| 25 |
+.. code-block:: bash |
|
| 31 | 26 |
|
| 32 |
-However, it is probably more useful to commit it to a specific name |
|
| 27 |
+ # for example docker commit $CONTAINER_ID dhrp/kickassapp |
|
| 28 |
+ docker commit <container_id> <your username>/<some_name> |
|
| 33 | 29 |
|
| 34 |
-:: |
|
| 35 | 30 |
|
| 36 |
- docker commit <container_id> <your username>/some_name |
|
| 37 |
- |
|
| 38 |
- |
|
| 39 |
-Committing a container to the repository |
|
| 31 |
+Pushing a container to the repository |
|
| 40 | 32 |
----------------------------------------- |
| 41 | 33 |
|
| 42 |
-In order to push an image to the repository you need to have committed your container to a named image including your |
|
| 43 |
-repository username. e.g. by doing: docker commit <container_id> dhrp/nodejs |
|
| 34 |
+In order to push an image to the repository you need to have committed your container to a named image (see above) |
|
| 44 | 35 |
|
| 45 | 36 |
Now you can commit this image to the repository |
| 46 | 37 |
|
| 47 |
-:: |
|
| 48 |
- |
|
| 49 |
- docker push image-name |
|
| 38 |
+.. code-block:: bash |
|
| 50 | 39 |
|
| 51 |
- # for example docker push dhrp/nodejs |
|
| 40 |
+ # for example docker push dhrp/kickassapp |
|
| 41 |
+ docker push <image-name> |
|
| 52 | 42 |
|
| ... | ... |
@@ -6,9 +6,7 @@ |
| 6 | 6 |
|
| 7 | 7 |
Hello World |
| 8 | 8 |
=========== |
| 9 |
-This is the most basic example available for using docker |
|
| 10 |
- |
|
| 11 |
-This example assumes you have Docker installed. |
|
| 9 |
+This is the most basic example available for using Docker. The example assumes you have Docker installed. |
|
| 12 | 10 |
|
| 13 | 11 |
|
| 14 | 12 |
Download the base container |
| ... | ... |
@@ -79,11 +79,3 @@ See the example in action |
| 79 | 79 |
</div> |
| 80 | 80 |
|
| 81 | 81 |
Continue to the :ref:`python_web_app` example. |
| 82 |
- |
|
| 83 |
- |
|
| 84 |
-Notes: |
|
| 85 |
- |
|
| 86 |
-- **Docker daemon** The docker daemon is started by ``sudo docker -d``, Vagrant may have started |
|
| 87 |
- the Docker daemon for you, but you will need to restart it this way if it was terminated. Otherwise |
|
| 88 |
- it may give you ``Couldn't create Tag store: open /var/lib/docker/repositories: permission denied`` |
| ... | ... |
@@ -5,43 +5,43 @@ FAQ |
| 5 | 5 |
Most frequently asked questions. |
| 6 | 6 |
-------------------------------- |
| 7 | 7 |
|
| 8 |
-**1. How much does Docker cost?** |
|
| 8 |
+1. **How much does Docker cost?** |
|
| 9 | 9 |
|
| 10 |
-Docker is 100% free, it is open source, so you can use it without paying. |
|
| 10 |
+ Docker is 100% free, it is open source, so you can use it without paying. |
|
| 11 | 11 |
|
| 12 |
-**2. What open source license are you using?** |
|
| 12 |
+2. **What open source license are you using?** |
|
| 13 | 13 |
|
| 14 |
-We are using the Apache License Version 2.0, see it here: https://github.com/dotcloud/docker/blob/master/LICENSE |
|
| 14 |
+ We are using the Apache License Version 2.0, see it here: https://github.com/dotcloud/docker/blob/master/LICENSE |
|
| 15 | 15 |
|
| 16 |
-**3. Does Docker run on Mac OS X or Windows?** |
|
| 16 |
+3. **Does Docker run on Mac OS X or Windows?** |
|
| 17 | 17 |
|
| 18 |
-Not at this time, Docker currently only runs on Linux, but you can use VirtualBox to run Docker in a virtual machine on your box, and get the best of both worlds. Check out the MacOSX_ and Windows_ intallation guides. |
|
| 18 |
+ Not at this time, Docker currently only runs on Linux, but you can use VirtualBox to run Docker in a virtual machine on your box, and get the best of both worlds. Check out the MacOSX_ and Windows_ intallation guides. |
|
| 19 | 19 |
|
| 20 |
-**4. How do containers compare to virtual machines?** |
|
| 20 |
+4. **How do containers compare to virtual machines?** |
|
| 21 | 21 |
|
| 22 |
-They are complementary. VMs are best used to allocate chunks of hardware resources. Containers operate at the process level, which makes them very lightweight and perfect as a unit of software delivery. |
|
| 22 |
+ They are complementary. VMs are best used to allocate chunks of hardware resources. Containers operate at the process level, which makes them very lightweight and perfect as a unit of software delivery. |
|
| 23 | 23 |
|
| 24 |
-**5. Can I help by adding some questions and answers?** |
|
| 24 |
+5. **Can I help by adding some questions and answers?** |
|
| 25 | 25 |
|
| 26 |
-Definitely! You can fork `the repo`_ and edit the documentation sources. |
|
| 26 |
+ Definitely! You can fork `the repo`_ and edit the documentation sources. |
|
| 27 | 27 |
|
| 28 | 28 |
|
| 29 |
-**42. Where can I find more answers?** |
|
| 29 |
+42. **Where can I find more answers?** |
|
| 30 | 30 |
|
| 31 |
-You can find more answers on: |
|
| 31 |
+ You can find more answers on: |
|
| 32 | 32 |
|
| 33 |
-* `IRC: docker on freenode`_ |
|
| 34 |
-* `Github`_ |
|
| 35 |
-* `Ask questions on Stackoverflow`_ |
|
| 36 |
-* `Join the conversation on Twitter`_ |
|
| 33 |
+ * `IRC: docker on freenode`_ |
|
| 34 |
+ * `Github`_ |
|
| 35 |
+ * `Ask questions on Stackoverflow`_ |
|
| 36 |
+ * `Join the conversation on Twitter`_ |
|
| 37 | 37 |
|
| 38 |
-.. _Windows: ../documentation/installation/windows.html |
|
| 39 |
-.. _MacOSX: ../documentation/installation/macos.html |
|
| 40 |
-.. _the repo: http://www.github.com/dotcloud/docker |
|
| 41 |
-.. _IRC\: docker on freenode: irc://chat.freenode.net#docker |
|
| 42 |
-.. _Github: http://www.github.com/dotcloud/docker |
|
| 43 |
-.. _Ask questions on Stackoverflow: http://stackoverflow.com/search?q=docker |
|
| 44 |
-.. _Join the conversation on Twitter: http://twitter.com/getdocker |
|
| 38 |
+ .. _Windows: ../documentation/installation/windows.html |
|
| 39 |
+ .. _MacOSX: ../documentation/installation/macos.html |
|
| 40 |
+ .. _the repo: http://www.github.com/dotcloud/docker |
|
| 41 |
+ .. _IRC\: docker on freenode: irc://chat.freenode.net#docker |
|
| 42 |
+ .. _Github: http://www.github.com/dotcloud/docker |
|
| 43 |
+ .. _Ask questions on Stackoverflow: http://stackoverflow.com/search?q=docker |
|
| 44 |
+ .. _Join the conversation on Twitter: http://twitter.com/getdocker |
|
| 45 | 45 |
|
| 46 | 46 |
|
| 47 | 47 |
Looking for something else to read? Checkout the :ref:`hello_world` example. |
| ... | ... |
@@ -42,7 +42,15 @@ Run your first container! |
| 42 | 42 |
|
| 43 | 43 |
sudo ./docker run -i -t base /bin/bash |
| 44 | 44 |
|
| 45 |
-Consider adding docker to your PATH for simplicity. |
|
| 46 | 45 |
|
| 46 |
+To run docker as a daemon, in the background, and allow non-root users to run ``docker`` start |
|
| 47 |
+docker -d |
|
| 48 |
+ |
|
| 49 |
+:: |
|
| 50 |
+ |
|
| 51 |
+ sudo ./docker -d & |
|
| 52 |
+ |
|
| 53 |
+ |
|
| 54 |
+Consider adding docker to your PATH for simplicity. |
|
| 47 | 55 |
|
| 48 | 56 |
Continue with the :ref:`hello_world` example. |
| 49 | 57 |
\ No newline at end of file |