Improve code/comment/output markings & display consistency
| ... | ... |
@@ -26,7 +26,7 @@ corresponding to existing containers. |
| 26 | 26 |
|
| 27 | 27 |
To figure out where your control groups are mounted, you can run: |
| 28 | 28 |
|
| 29 |
- grep cgroup /proc/mounts |
|
| 29 |
+ $ grep cgroup /proc/mounts |
|
| 30 | 30 |
|
| 31 | 31 |
## Enumerating Cgroups |
| 32 | 32 |
|
| ... | ... |
@@ -287,7 +287,7 @@ an interface) can do some serious accounting. |
| 287 | 287 |
For instance, you can setup a rule to account for the outbound HTTP |
| 288 | 288 |
traffic on a web server: |
| 289 | 289 |
|
| 290 |
- iptables -I OUTPUT -p tcp --sport 80 |
|
| 290 |
+ $ iptables -I OUTPUT -p tcp --sport 80 |
|
| 291 | 291 |
|
| 292 | 292 |
There is no `-j` or `-g` flag, |
| 293 | 293 |
so the rule will just count matched packets and go to the following |
| ... | ... |
@@ -295,7 +295,7 @@ rule. |
| 295 | 295 |
|
| 296 | 296 |
Later, you can check the values of the counters, with: |
| 297 | 297 |
|
| 298 |
- iptables -nxvL OUTPUT |
|
| 298 |
+ $ iptables -nxvL OUTPUT |
|
| 299 | 299 |
|
| 300 | 300 |
Technically, `-n` is not required, but it will |
| 301 | 301 |
prevent iptables from doing DNS reverse lookups, which are probably |
| ... | ... |
@@ -337,11 +337,11 @@ though. |
| 337 | 337 |
|
| 338 | 338 |
The exact format of the command is: |
| 339 | 339 |
|
| 340 |
- ip netns exec <nsname> <command...> |
|
| 340 |
+ $ ip netns exec <nsname> <command...> |
|
| 341 | 341 |
|
| 342 | 342 |
For example: |
| 343 | 343 |
|
| 344 |
- ip netns exec mycontainer netstat -i |
|
| 344 |
+ $ ip netns exec mycontainer netstat -i |
|
| 345 | 345 |
|
| 346 | 346 |
`ip netns` finds the "mycontainer" container by |
| 347 | 347 |
using namespaces pseudo-files. Each process belongs to one network |
| ... | ... |
@@ -369,14 +369,13 @@ measure network usage. From there, you can examine the pseudo-file named |
| 369 | 369 |
control group (i.e. in the container). Pick any one of them. |
| 370 | 370 |
|
| 371 | 371 |
Putting everything together, if the "short ID" of a container is held in |
| 372 |
-the environment variable `$CID`, then you can do |
|
| 373 |
-this: |
|
| 374 |
- |
|
| 375 |
- TASKS=/sys/fs/cgroup/devices/$CID*/tasks |
|
| 376 |
- PID=$(head -n 1 $TASKS) |
|
| 377 |
- mkdir -p /var/run/netns |
|
| 378 |
- ln -sf /proc/$PID/ns/net /var/run/netns/$CID |
|
| 379 |
- ip netns exec $CID netstat -i |
|
| 372 |
+the environment variable `$CID`, then you can do this: |
|
| 373 |
+ |
|
| 374 |
+ $ TASKS=/sys/fs/cgroup/devices/$CID*/tasks |
|
| 375 |
+ $ PID=$(head -n 1 $TASKS) |
|
| 376 |
+ $ mkdir -p /var/run/netns |
|
| 377 |
+ $ ln -sf /proc/$PID/ns/net /var/run/netns/$CID |
|
| 378 |
+ $ ip netns exec $CID netstat -i |
|
| 380 | 379 |
|
| 381 | 380 |
## Tips for high-performance metric collection |
| 382 | 381 |
|
| ... | ... |
@@ -32,8 +32,8 @@ Again, you can do it in other ways but you need to do more work. |
| 32 | 32 |
|
| 33 | 33 |
## Check out the Source |
| 34 | 34 |
|
| 35 |
- git clone http://git@github.com/dotcloud/docker |
|
| 36 |
- cd docker |
|
| 35 |
+ $ git clone http://git@github.com/dotcloud/docker |
|
| 36 |
+ $ cd docker |
|
| 37 | 37 |
|
| 38 | 38 |
To checkout a different revision just use `git checkout` |
| 39 | 39 |
with the name of branch or revision number. |
| ... | ... |
@@ -45,7 +45,7 @@ Dockerfile in the current directory. Essentially, it will install all |
| 45 | 45 |
the build and runtime dependencies necessary to build and test Docker. |
| 46 | 46 |
This command will take some time to complete when you first execute it. |
| 47 | 47 |
|
| 48 |
- sudo make build |
|
| 48 |
+ $ sudo make build |
|
| 49 | 49 |
|
| 50 | 50 |
If the build is successful, congratulations! You have produced a clean |
| 51 | 51 |
build of docker, neatly encapsulated in a standard build environment. |
| ... | ... |
@@ -54,7 +54,7 @@ build of docker, neatly encapsulated in a standard build environment. |
| 54 | 54 |
|
| 55 | 55 |
To create the Docker binary, run this command: |
| 56 | 56 |
|
| 57 |
- sudo make binary |
|
| 57 |
+ $ sudo make binary |
|
| 58 | 58 |
|
| 59 | 59 |
This will create the Docker binary in `./bundles/<version>-dev/binary/` |
| 60 | 60 |
|
| ... | ... |
@@ -65,7 +65,7 @@ The binary is available outside the container in the directory |
| 65 | 65 |
host docker executable with this binary for live testing - for example, |
| 66 | 66 |
on ubuntu: |
| 67 | 67 |
|
| 68 |
- sudo service docker stop ; sudo cp $(which docker) $(which docker)_ ; sudo cp ./bundles/<version>-dev/binary/docker-<version>-dev $(which docker);sudo service docker start |
|
| 68 |
+ $ sudo service docker stop ; sudo cp $(which docker) $(which docker)_ ; sudo cp ./bundles/<version>-dev/binary/docker-<version>-dev $(which docker);sudo service docker start |
|
| 69 | 69 |
|
| 70 | 70 |
> **Note**: |
| 71 | 71 |
> Its safer to run the tests below before swapping your hosts docker binary. |
| ... | ... |
@@ -74,7 +74,7 @@ on ubuntu: |
| 74 | 74 |
|
| 75 | 75 |
To execute the test cases, run this command: |
| 76 | 76 |
|
| 77 |
- sudo make test |
|
| 77 |
+ $ sudo make test |
|
| 78 | 78 |
|
| 79 | 79 |
If the test are successful then the tail of the output should look |
| 80 | 80 |
something like this |
| ... | ... |
@@ -105,11 +105,10 @@ something like this |
| 105 | 105 |
PASS |
| 106 | 106 |
ok github.com/dotcloud/docker/utils 0.017s |
| 107 | 107 |
|
| 108 |
-If $TESTFLAGS is set in the environment, it is passed as extra |
|
| 109 |
-arguments to `go test`. You can use this to select certain tests to run, |
|
| 110 |
-eg. |
|
| 108 |
+If $TESTFLAGS is set in the environment, it is passed as extra arguments |
|
| 109 |
+to `go test`. You can use this to select certain tests to run, e.g. |
|
| 111 | 110 |
|
| 112 |
- TESTFLAGS=`-run \^TestBuild\$` make test |
|
| 111 |
+ $ TESTFLAGS=`-run \^TestBuild\$` make test |
|
| 113 | 112 |
|
| 114 | 113 |
If the output indicates "FAIL" and you see errors like this: |
| 115 | 114 |
|
| ... | ... |
@@ -124,7 +123,7 @@ is recommended. |
| 124 | 124 |
|
| 125 | 125 |
You can run an interactive session in the newly built container: |
| 126 | 126 |
|
| 127 |
- sudo make shell |
|
| 127 |
+ $ sudo make shell |
|
| 128 | 128 |
|
| 129 | 129 |
# type 'exit' or Ctrl-D to exit |
| 130 | 130 |
|
| ... | ... |
@@ -134,7 +133,7 @@ If you want to read the documentation from a local website, or are |
| 134 | 134 |
making changes to it, you can build the documentation and then serve it |
| 135 | 135 |
by: |
| 136 | 136 |
|
| 137 |
- sudo make docs |
|
| 137 |
+ $ sudo make docs |
|
| 138 | 138 |
|
| 139 | 139 |
# when its done, you can point your browser to http://yourdockerhost:8000 |
| 140 | 140 |
# type Ctrl-C to exit |
| ... | ... |
@@ -95,7 +95,7 @@ your container with the docker build command, e.g. |
| 95 | 95 |
Start the container with `apache2` and `sshd` running and managed, forwarding |
| 96 | 96 |
a port to our SSH instance: |
| 97 | 97 |
|
| 98 |
- docker run -p 127.0.0.1:222:22 -d managed_image "/usr/sbin/sshd" "/etc/init.d/apache2 start" |
|
| 98 |
+ $ docker run -p 127.0.0.1:222:22 -d managed_image "/usr/sbin/sshd" "/etc/init.d/apache2 start" |
|
| 99 | 99 |
|
| 100 | 100 |
We now clearly see one of the benefits of the cfe-docker integration: it |
| 101 | 101 |
allows to start several processes as part of a normal `docker run` command. |
| ... | ... |
@@ -20,28 +20,28 @@ different versions of CouchDB on the same data, etc. |
| 20 | 20 |
|
| 21 | 21 |
Note that we're marking `/var/lib/couchdb` as a data volume. |
| 22 | 22 |
|
| 23 |
- COUCH1=$(sudo docker run -d -p 5984 -v /var/lib/couchdb shykes/couchdb:2013-05-03) |
|
| 23 |
+ $ COUCH1=$(sudo docker run -d -p 5984 -v /var/lib/couchdb shykes/couchdb:2013-05-03) |
|
| 24 | 24 |
|
| 25 | 25 |
## Add data to the first database |
| 26 | 26 |
|
| 27 | 27 |
We're assuming your Docker host is reachable at `localhost`. If not, |
| 28 | 28 |
replace `localhost` with the public IP of your Docker host. |
| 29 | 29 |
|
| 30 |
- HOST=localhost |
|
| 31 |
- URL="http://$HOST:$(sudo docker port $COUCH1 5984 | grep -Po '\d+$')/_utils/" |
|
| 32 |
- echo "Navigate to $URL in your browser, and use the couch interface to add data" |
|
| 30 |
+ $ HOST=localhost |
|
| 31 |
+ $ URL="http://$HOST:$(sudo docker port $COUCH1 5984 | grep -Po '\d+$')/_utils/" |
|
| 32 |
+ $ echo "Navigate to $URL in your browser, and use the couch interface to add data" |
|
| 33 | 33 |
|
| 34 | 34 |
## Create second database |
| 35 | 35 |
|
| 36 | 36 |
This time, we're requesting shared access to `$COUCH1`'s volumes. |
| 37 | 37 |
|
| 38 |
- COUCH2=$(sudo docker run -d -p 5984 --volumes-from $COUCH1 shykes/couchdb:2013-05-03) |
|
| 38 |
+ $ COUCH2=$(sudo docker run -d -p 5984 --volumes-from $COUCH1 shykes/couchdb:2013-05-03) |
|
| 39 | 39 |
|
| 40 | 40 |
## Browse data on the second database |
| 41 | 41 |
|
| 42 |
- HOST=localhost |
|
| 43 |
- URL="http://$HOST:$(sudo docker port $COUCH2 5984 | grep -Po '\d+$')/_utils/" |
|
| 44 |
- echo "Navigate to $URL in your browser. You should see the same data as in the first database"'!' |
|
| 42 |
+ $ HOST=localhost |
|
| 43 |
+ $ URL="http://$HOST:$(sudo docker port $COUCH2 5984 | grep -Po '\d+$')/_utils/" |
|
| 44 |
+ $ echo "Navigate to $URL in your browser. You should see the same data as in the first database"'!' |
|
| 45 | 45 |
|
| 46 | 46 |
Congratulations, you are now running two Couchdb containers, completely |
| 47 | 47 |
isolated from each other *except* for their data. |
| ... | ... |
@@ -80,7 +80,7 @@ continue to do this until we stop it. |
| 80 | 80 |
|
| 81 | 81 |
**Steps:** |
| 82 | 82 |
|
| 83 |
- CONTAINER_ID=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done") |
|
| 83 |
+ $ CONTAINER_ID=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done") |
|
| 84 | 84 |
|
| 85 | 85 |
We are going to run a simple hello world daemon in a new container made |
| 86 | 86 |
from the `ubuntu` image. |
| ... | ... |
@@ -98,7 +98,7 @@ from the `ubuntu` image. |
| 98 | 98 |
|
| 99 | 99 |
<!-- --> |
| 100 | 100 |
|
| 101 |
- sudo docker logs $container_id |
|
| 101 |
+ $ sudo docker logs $container_id |
|
| 102 | 102 |
|
| 103 | 103 |
Check the logs make sure it is working correctly. |
| 104 | 104 |
|
| ... | ... |
@@ -107,7 +107,7 @@ Check the logs make sure it is working correctly. |
| 107 | 107 |
|
| 108 | 108 |
<!-- --> |
| 109 | 109 |
|
| 110 |
- sudo docker attach --sig-proxy=false $container_id |
|
| 110 |
+ $ sudo docker attach --sig-proxy=false $container_id |
|
| 111 | 111 |
|
| 112 | 112 |
Attach to the container to see the results in real-time. |
| 113 | 113 |
|
| ... | ... |
@@ -120,7 +120,7 @@ Attach to the container to see the results in real-time. |
| 120 | 120 |
|
| 121 | 121 |
Exit from the container attachment by pressing Control-C. |
| 122 | 122 |
|
| 123 |
- sudo docker ps |
|
| 123 |
+ $ sudo docker ps |
|
| 124 | 124 |
|
| 125 | 125 |
Check the process list to make sure it is running. |
| 126 | 126 |
|
| ... | ... |
@@ -128,7 +128,7 @@ Check the process list to make sure it is running. |
| 128 | 128 |
|
| 129 | 129 |
<!-- --> |
| 130 | 130 |
|
| 131 |
- sudo docker stop $container_id |
|
| 131 |
+ $ sudo docker stop $container_id |
|
| 132 | 132 |
|
| 133 | 133 |
Stop the container, since we don't need it anymore. |
| 134 | 134 |
|
| ... | ... |
@@ -137,7 +137,7 @@ Stop the container, since we don't need it anymore. |
| 137 | 137 |
|
| 138 | 138 |
<!-- --> |
| 139 | 139 |
|
| 140 |
- sudo docker ps |
|
| 140 |
+ $ sudo docker ps |
|
| 141 | 141 |
|
| 142 | 142 |
Make sure it is really stopped. |
| 143 | 143 |
|
| ... | ... |
@@ -21,7 +21,7 @@ apt source and installs the database software on Ubuntu. |
| 21 | 21 |
|
| 22 | 22 |
Create an empty file called Dockerfile: |
| 23 | 23 |
|
| 24 |
- touch Dockerfile |
|
| 24 |
+ $ touch Dockerfile |
|
| 25 | 25 |
|
| 26 | 26 |
Next, define the parent image you want to use to build your own image on |
| 27 | 27 |
top of. Here, we'll use [Ubuntu](https://index.docker.io/_/ubuntu/) |
| ... | ... |
@@ -69,21 +69,21 @@ container. |
| 69 | 69 |
Now, lets build the image which will go through the |
| 70 | 70 |
Dockerfile we made and run all of the commands. |
| 71 | 71 |
|
| 72 |
- sudo docker build -t <yourname>/mongodb . |
|
| 72 |
+ $ sudo docker build -t <yourname>/mongodb . |
|
| 73 | 73 |
|
| 74 | 74 |
Now you should be able to run `mongod` as a daemon |
| 75 | 75 |
and be able to connect on the local port! |
| 76 | 76 |
|
| 77 | 77 |
# Regular style |
| 78 |
- MONGO_ID=$(sudo docker run -d <yourname>/mongodb) |
|
| 78 |
+ $ MONGO_ID=$(sudo docker run -d <yourname>/mongodb) |
|
| 79 | 79 |
|
| 80 | 80 |
# Lean and mean |
| 81 |
- MONGO_ID=$(sudo docker run -d <yourname>/mongodb --noprealloc --smallfiles) |
|
| 81 |
+ $ MONGO_ID=$(sudo docker run -d <yourname>/mongodb --noprealloc --smallfiles) |
|
| 82 | 82 |
|
| 83 | 83 |
# Check the logs out |
| 84 |
- sudo docker logs $MONGO_ID |
|
| 84 |
+ $ sudo docker logs $MONGO_ID |
|
| 85 | 85 |
|
| 86 | 86 |
# Connect and play around |
| 87 |
- mongo --port <port you get from `docker ps`> |
|
| 87 |
+ $ mongo --port <port you get from `docker ps`> |
|
| 88 | 88 |
|
| 89 | 89 |
Sweet! |
| ... | ... |
@@ -134,16 +134,16 @@ Go to the directory that has your `Dockerfile` and run the following command |
| 134 | 134 |
to build a Docker image. The `-t` flag let's you tag your image so it's easier |
| 135 | 135 |
to find later using the `docker images` command: |
| 136 | 136 |
|
| 137 |
- sudo docker build -t <your username>/centos-node-hello . |
|
| 137 |
+ $ sudo docker build -t <your username>/centos-node-hello . |
|
| 138 | 138 |
|
| 139 | 139 |
Your image will now be listed by Docker: |
| 140 | 140 |
|
| 141 |
- sudo docker images |
|
| 141 |
+ $ sudo docker images |
|
| 142 | 142 |
|
| 143 |
- > # Example |
|
| 144 |
- > REPOSITORY TAG ID CREATED |
|
| 145 |
- > centos 6.4 539c0211cd76 8 weeks ago |
|
| 146 |
- > gasi/centos-node-hello latest d64d3505b0d2 2 hours ago |
|
| 143 |
+ # Example |
|
| 144 |
+ REPOSITORY TAG ID CREATED |
|
| 145 |
+ centos 6.4 539c0211cd76 8 weeks ago |
|
| 146 |
+ gasi/centos-node-hello latest d64d3505b0d2 2 hours ago |
|
| 147 | 147 |
|
| 148 | 148 |
## Run the image |
| 149 | 149 |
|
| ... | ... |
@@ -151,44 +151,44 @@ Running your image with `-d` runs the container in detached mode, leaving the |
| 151 | 151 |
container running in the background. The `-p` flag redirects a public port to |
| 152 | 152 |
a private port in the container. Run the image you previously built: |
| 153 | 153 |
|
| 154 |
- sudo docker run -p 49160:8080 -d <your username>/centos-node-hello |
|
| 154 |
+ $ sudo docker run -p 49160:8080 -d <your username>/centos-node-hello |
|
| 155 | 155 |
|
| 156 | 156 |
Print the output of your app: |
| 157 | 157 |
|
| 158 | 158 |
# Get container ID |
| 159 |
- sudo docker ps |
|
| 159 |
+ $ sudo docker ps |
|
| 160 | 160 |
|
| 161 | 161 |
# Print app output |
| 162 |
- sudo docker logs <container id> |
|
| 162 |
+ $ sudo docker logs <container id> |
|
| 163 | 163 |
|
| 164 |
- > # Example |
|
| 165 |
- > Running on http://localhost:8080 |
|
| 164 |
+ # Example |
|
| 165 |
+ Running on http://localhost:8080 |
|
| 166 | 166 |
|
| 167 | 167 |
## Test |
| 168 | 168 |
|
| 169 | 169 |
To test your app, get the the port of your app that Docker mapped: |
| 170 | 170 |
|
| 171 |
- sudo docker ps |
|
| 171 |
+ $ sudo docker ps |
|
| 172 | 172 |
|
| 173 |
- > # Example |
|
| 174 |
- > ID IMAGE COMMAND ... PORTS |
|
| 175 |
- > ecce33b30ebf gasi/centos-node-hello:latest node /src/index.js 49160->8080 |
|
| 173 |
+ # Example |
|
| 174 |
+ ID IMAGE COMMAND ... PORTS |
|
| 175 |
+ ecce33b30ebf gasi/centos-node-hello:latest node /src/index.js 49160->8080 |
|
| 176 | 176 |
|
| 177 | 177 |
In the example above, Docker mapped the `8080` port of the container to `49160`. |
| 178 | 178 |
|
| 179 | 179 |
Now you can call your app using `curl` (install if needed via: |
| 180 | 180 |
`sudo apt-get install curl`): |
| 181 | 181 |
|
| 182 |
- curl -i localhost:49160 |
|
| 182 |
+ $ curl -i localhost:49160 |
|
| 183 | 183 |
|
| 184 |
- > HTTP/1.1 200 OK |
|
| 185 |
- > X-Powered-By: Express |
|
| 186 |
- > Content-Type: text/html; charset=utf-8 |
|
| 187 |
- > Content-Length: 12 |
|
| 188 |
- > Date: Sun, 02 Jun 2013 03:53:22 GMT |
|
| 189 |
- > Connection: keep-alive |
|
| 190 |
- > |
|
| 191 |
- > Hello World |
|
| 184 |
+ HTTP/1.1 200 OK |
|
| 185 |
+ X-Powered-By: Express |
|
| 186 |
+ Content-Type: text/html; charset=utf-8 |
|
| 187 |
+ Content-Length: 12 |
|
| 188 |
+ Date: Sun, 02 Jun 2013 03:53:22 GMT |
|
| 189 |
+ Connection: keep-alive |
|
| 190 |
+ |
|
| 191 |
+ Hello World |
|
| 192 | 192 |
|
| 193 | 193 |
We hope this tutorial helped you get up and running with Node.js and |
| 194 | 194 |
CentOS on Docker. You can get the full source code at |
| ... | ... |
@@ -125,14 +125,14 @@ prompt, you can create a table and populate it. |
| 125 | 125 |
psql (9.3.1) |
| 126 | 126 |
Type "help" for help. |
| 127 | 127 |
|
| 128 |
- docker=# CREATE TABLE cities ( |
|
| 128 |
+ $ docker=# CREATE TABLE cities ( |
|
| 129 | 129 |
docker(# name varchar(80), |
| 130 | 130 |
docker(# location point |
| 131 | 131 |
docker(# ); |
| 132 | 132 |
CREATE TABLE |
| 133 |
- docker=# INSERT INTO cities VALUES ('San Francisco', '(-194.0, 53.0)');
|
|
| 133 |
+ $ docker=# INSERT INTO cities VALUES ('San Francisco', '(-194.0, 53.0)');
|
|
| 134 | 134 |
INSERT 0 1 |
| 135 |
- docker=# select * from cities; |
|
| 135 |
+ $ docker=# select * from cities; |
|
| 136 | 136 |
name | location |
| 137 | 137 |
---------------+----------- |
| 138 | 138 |
San Francisco | (-194,53) |
| ... | ... |
@@ -143,7 +143,7 @@ prompt, you can create a table and populate it. |
| 143 | 143 |
You can use the defined volumes to inspect the PostgreSQL log files and |
| 144 | 144 |
to backup your configuration and data: |
| 145 | 145 |
|
| 146 |
- docker run -rm --volumes-from pg_test -t -i busybox sh |
|
| 146 |
+ $ docker run -rm --volumes-from pg_test -t -i busybox sh |
|
| 147 | 147 |
|
| 148 | 148 |
/ # ls |
| 149 | 149 |
bin etc lib linuxrc mnt proc run sys usr |
| ... | ... |
@@ -29,7 +29,7 @@ image. |
| 29 | 29 |
Next we build an image from our `Dockerfile`. |
| 30 | 30 |
Replace `<your username>` with your own user name. |
| 31 | 31 |
|
| 32 |
- sudo docker build -t <your username>/redis . |
|
| 32 |
+ $ sudo docker build -t <your username>/redis . |
|
| 33 | 33 |
|
| 34 | 34 |
## Run the service |
| 35 | 35 |
|
| ... | ... |
@@ -42,7 +42,7 @@ Importantly, we're not exposing any ports on our container. Instead |
| 42 | 42 |
we're going to use a container link to provide access to our Redis |
| 43 | 43 |
database. |
| 44 | 44 |
|
| 45 |
- sudo docker run --name redis -d <your username>/redis |
|
| 45 |
+ $ sudo docker run --name redis -d <your username>/redis |
|
| 46 | 46 |
|
| 47 | 47 |
## Create your web application container |
| 48 | 48 |
|
| ... | ... |
@@ -52,19 +52,19 @@ created with an alias of `db`. This will create a secure tunnel to the |
| 52 | 52 |
`redis` container and expose the Redis instance running inside that |
| 53 | 53 |
container to only this container. |
| 54 | 54 |
|
| 55 |
- sudo docker run --link redis:db -i -t ubuntu:12.10 /bin/bash |
|
| 55 |
+ $ sudo docker run --link redis:db -i -t ubuntu:12.10 /bin/bash |
|
| 56 | 56 |
|
| 57 | 57 |
Once inside our freshly created container we need to install Redis to |
| 58 | 58 |
get the `redis-cli` binary to test our connection. |
| 59 | 59 |
|
| 60 |
- apt-get update |
|
| 61 |
- apt-get -y install redis-server |
|
| 62 |
- service redis-server stop |
|
| 60 |
+ $ apt-get update |
|
| 61 |
+ $ apt-get -y install redis-server |
|
| 62 |
+ $ service redis-server stop |
|
| 63 | 63 |
|
| 64 | 64 |
As we've used the `--link redis:db` option, Docker |
| 65 | 65 |
has created some environment variables in our web application container. |
| 66 | 66 |
|
| 67 |
- env | grep DB_ |
|
| 67 |
+ $ env | grep DB_ |
|
| 68 | 68 |
|
| 69 | 69 |
# Should return something similar to this with your values |
| 70 | 70 |
DB_NAME=/violet_wolf/db |
| ... | ... |
@@ -79,13 +79,13 @@ with `DB`. The `DB` comes from the link alias specified when we launched |
| 79 | 79 |
the container. Let's use the `DB_PORT_6379_TCP_ADDR` variable to connect to |
| 80 | 80 |
our Redis container. |
| 81 | 81 |
|
| 82 |
- redis-cli -h $DB_PORT_6379_TCP_ADDR |
|
| 83 |
- redis 172.17.0.33:6379> |
|
| 84 |
- redis 172.17.0.33:6379> set docker awesome |
|
| 82 |
+ $ redis-cli -h $DB_PORT_6379_TCP_ADDR |
|
| 83 |
+ $ redis 172.17.0.33:6379> |
|
| 84 |
+ $ redis 172.17.0.33:6379> set docker awesome |
|
| 85 | 85 |
OK |
| 86 |
- redis 172.17.0.33:6379> get docker |
|
| 86 |
+ $ redis 172.17.0.33:6379> get docker |
|
| 87 | 87 |
"awesome" |
| 88 |
- redis 172.17.0.33:6379> exit |
|
| 88 |
+ $ redis 172.17.0.33:6379> exit |
|
| 89 | 89 |
|
| 90 | 90 |
We could easily use this or other environment variables in our web |
| 91 | 91 |
application to make a connection to our `redis` |
| ... | ... |
@@ -19,7 +19,7 @@ Riak pre-installed. |
| 19 | 19 |
|
| 20 | 20 |
Create an empty file called Dockerfile: |
| 21 | 21 |
|
| 22 |
- touch Dockerfile |
|
| 22 |
+ $ touch Dockerfile |
|
| 23 | 23 |
|
| 24 | 24 |
Next, define the parent image you want to use to build your image on top |
| 25 | 25 |
of. We'll use [Ubuntu](https://index.docker.io/_/ubuntu/) (tag: |
| ... | ... |
@@ -126,7 +126,7 @@ Populate it with the following program definitions: |
| 126 | 126 |
|
| 127 | 127 |
Now you should be able to build a Docker image for Riak: |
| 128 | 128 |
|
| 129 |
- docker build -t "<yourname>/riak" . |
|
| 129 |
+ $ docker build -t "<yourname>/riak" . |
|
| 130 | 130 |
|
| 131 | 131 |
## Next steps |
| 132 | 132 |
|
| ... | ... |
@@ -99,13 +99,13 @@ launches. |
| 99 | 99 |
|
| 100 | 100 |
We can now build our new container. |
| 101 | 101 |
|
| 102 |
- sudo docker build -t <yourname>/supervisord . |
|
| 102 |
+ $ sudo docker build -t <yourname>/supervisord . |
|
| 103 | 103 |
|
| 104 | 104 |
## Running our Supervisor container |
| 105 | 105 |
|
| 106 | 106 |
Once We've got a built image we can launch a container from it. |
| 107 | 107 |
|
| 108 |
- sudo docker run -p 22 -p 80 -t -i <yourname>/supervisord |
|
| 108 |
+ $ sudo docker run -p 22 -p 80 -t -i <yourname>/supervisord |
|
| 109 | 109 |
2013-11-25 18:53:22,312 CRIT Supervisor running as root (no user in config file) |
| 110 | 110 |
2013-11-25 18:53:22,312 WARN Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing |
| 111 | 111 |
2013-11-25 18:53:22,342 INFO supervisord started with pid 1 |
| ... | ... |
@@ -60,8 +60,8 @@ have not done so before. |
| 60 | 60 |
There is a systemd service unit created for docker. To start the docker |
| 61 | 61 |
service: |
| 62 | 62 |
|
| 63 |
- sudo systemctl start docker |
|
| 63 |
+ $ sudo systemctl start docker |
|
| 64 | 64 |
|
| 65 | 65 |
To start on system boot: |
| 66 | 66 |
|
| 67 |
- sudo systemctl enable docker |
|
| 67 |
+ $ sudo systemctl enable docker |
| ... | ... |
@@ -46,8 +46,8 @@ Linux kernel (it even builds on OSX!). |
| 46 | 46 |
|
| 47 | 47 |
## Get the docker binary: |
| 48 | 48 |
|
| 49 |
- wget https://get.docker.io/builds/Linux/x86_64/docker-latest -O docker |
|
| 50 |
- chmod +x docker |
|
| 49 |
+ $ wget https://get.docker.io/builds/Linux/x86_64/docker-latest -O docker |
|
| 50 |
+ $ chmod +x docker |
|
| 51 | 51 |
|
| 52 | 52 |
> **Note**: |
| 53 | 53 |
> If you have trouble downloading the binary, you can also get the smaller |
| ... | ... |
@@ -58,7 +58,7 @@ Linux kernel (it even builds on OSX!). |
| 58 | 58 |
## Run the docker daemon |
| 59 | 59 |
|
| 60 | 60 |
# start the docker in daemon mode from the directory you unpacked |
| 61 |
- sudo ./docker -d & |
|
| 61 |
+ $ sudo ./docker -d & |
|
| 62 | 62 |
|
| 63 | 63 |
## Giving non-root access |
| 64 | 64 |
|
| ... | ... |
@@ -87,16 +87,16 @@ all the client commands. |
| 87 | 87 |
To upgrade your manual installation of Docker, first kill the docker |
| 88 | 88 |
daemon: |
| 89 | 89 |
|
| 90 |
- killall docker |
|
| 90 |
+ $ killall docker |
|
| 91 | 91 |
|
| 92 | 92 |
Then follow the regular installation steps. |
| 93 | 93 |
|
| 94 | 94 |
## Run your first container! |
| 95 | 95 |
|
| 96 | 96 |
# check your docker version |
| 97 |
- sudo ./docker version |
|
| 97 |
+ $ sudo ./docker version |
|
| 98 | 98 |
|
| 99 | 99 |
# run a container and open an interactive shell in the container |
| 100 |
- sudo ./docker run -i -t ubuntu /bin/bash |
|
| 100 |
+ $ sudo ./docker run -i -t ubuntu /bin/bash |
|
| 101 | 101 |
|
| 102 | 102 |
Continue with the [*Hello World*](/examples/hello_world/#hello-world) example. |
| ... | ... |
@@ -39,24 +39,24 @@ do so via: |
| 39 | 39 |
Download the `httpup` file to |
| 40 | 40 |
`/etc/ports/`: |
| 41 | 41 |
|
| 42 |
- curl -q -o - http://crux.nu/portdb/?a=getup&q=prologic > /etc/ports/prologic.httpup |
|
| 42 |
+ $ curl -q -o - http://crux.nu/portdb/?a=getup&q=prologic > /etc/ports/prologic.httpup |
|
| 43 | 43 |
|
| 44 | 44 |
Add `prtdir /usr/ports/prologic` to |
| 45 | 45 |
`/etc/prt-get.conf`: |
| 46 | 46 |
|
| 47 |
- vim /etc/prt-get.conf |
|
| 47 |
+ $ vim /etc/prt-get.conf |
|
| 48 | 48 |
|
| 49 | 49 |
# or: |
| 50 |
- echo "prtdir /usr/ports/prologic" >> /etc/prt-get.conf |
|
| 50 |
+ $ echo "prtdir /usr/ports/prologic" >> /etc/prt-get.conf |
|
| 51 | 51 |
|
| 52 | 52 |
Update ports and prt-get cache: |
| 53 | 53 |
|
| 54 |
- ports -u |
|
| 55 |
- prt-get cache |
|
| 54 |
+ $ ports -u |
|
| 55 |
+ $ prt-get cache |
|
| 56 | 56 |
|
| 57 | 57 |
To install (*and its dependencies*): |
| 58 | 58 |
|
| 59 |
- prt-get depinst docker |
|
| 59 |
+ $ prt-get depinst docker |
|
| 60 | 60 |
|
| 61 | 61 |
Use `docker-bin` for the upstream binary or |
| 62 | 62 |
`docker-git` to build and install from the master |
| ... | ... |
@@ -70,20 +70,20 @@ and Docker Daemon to work properly. |
| 70 | 70 |
|
| 71 | 71 |
Please read the `README.rst`: |
| 72 | 72 |
|
| 73 |
- prt-get readme docker |
|
| 73 |
+ $ prt-get readme docker |
|
| 74 | 74 |
|
| 75 | 75 |
There is a `test_kernel_config.sh` script in the |
| 76 | 76 |
above ports which you can use to test your Kernel configuration: |
| 77 | 77 |
|
| 78 |
- cd /usr/ports/prologic/docker |
|
| 79 |
- ./test_kernel_config.sh /usr/src/linux/.config |
|
| 78 |
+ $ cd /usr/ports/prologic/docker |
|
| 79 |
+ $ ./test_kernel_config.sh /usr/src/linux/.config |
|
| 80 | 80 |
|
| 81 | 81 |
## Starting Docker |
| 82 | 82 |
|
| 83 | 83 |
There is a rc script created for Docker. To start the Docker service: |
| 84 | 84 |
|
| 85 |
- sudo su - |
|
| 86 |
- /etc/rc.d/docker start |
|
| 85 |
+ $ sudo su - |
|
| 86 |
+ $ /etc/rc.d/docker start |
|
| 87 | 87 |
|
| 88 | 88 |
To start on system boot: |
| 89 | 89 |
|
| ... | ... |
@@ -30,35 +30,35 @@ report](https://bugzilla.redhat.com/show_bug.cgi?id=1043676) filed for |
| 30 | 30 |
it. To proceed with `docker-io` installation on Fedora 19, please remove |
| 31 | 31 |
`docker` first. |
| 32 | 32 |
|
| 33 |
- sudo yum -y remove docker |
|
| 33 |
+ $ sudo yum -y remove docker |
|
| 34 | 34 |
|
| 35 | 35 |
For Fedora 20 and later, the `wmdocker` package will |
| 36 | 36 |
provide the same functionality as `docker` and will |
| 37 | 37 |
also not conflict with `docker-io`. |
| 38 | 38 |
|
| 39 |
- sudo yum -y install wmdocker |
|
| 40 |
- sudo yum -y remove docker |
|
| 39 |
+ $ sudo yum -y install wmdocker |
|
| 40 |
+ $ sudo yum -y remove docker |
|
| 41 | 41 |
|
| 42 | 42 |
Install the `docker-io` package which will install |
| 43 | 43 |
Docker on our host. |
| 44 | 44 |
|
| 45 |
- sudo yum -y install docker-io |
|
| 45 |
+ $ sudo yum -y install docker-io |
|
| 46 | 46 |
|
| 47 | 47 |
To update the `docker-io` package: |
| 48 | 48 |
|
| 49 |
- sudo yum -y update docker-io |
|
| 49 |
+ $ sudo yum -y update docker-io |
|
| 50 | 50 |
|
| 51 | 51 |
Now that it's installed, let's start the Docker daemon. |
| 52 | 52 |
|
| 53 |
- sudo systemctl start docker |
|
| 53 |
+ $ sudo systemctl start docker |
|
| 54 | 54 |
|
| 55 | 55 |
If we want Docker to start at boot, we should also: |
| 56 | 56 |
|
| 57 |
- sudo systemctl enable docker |
|
| 57 |
+ $ sudo systemctl enable docker |
|
| 58 | 58 |
|
| 59 | 59 |
Now let's verify that Docker is working. |
| 60 | 60 |
|
| 61 |
- sudo docker run -i -t fedora /bin/bash |
|
| 61 |
+ $ sudo docker run -i -t fedora /bin/bash |
|
| 62 | 62 |
|
| 63 | 63 |
**Done!**, now continue with the [*Hello |
| 64 | 64 |
World*](/examples/hello_world/#hello-world) example. |
| ... | ... |
@@ -49,8 +49,8 @@ is all that is needed. |
| 49 | 49 |
There is a systemd service unit created for Docker. To start Docker as |
| 50 | 50 |
service: |
| 51 | 51 |
|
| 52 |
- sudo systemctl start lxc-docker |
|
| 52 |
+ $ sudo systemctl start lxc-docker |
|
| 53 | 53 |
|
| 54 | 54 |
To start on system boot: |
| 55 | 55 |
|
| 56 |
- sudo systemctl enable lxc-docker |
|
| 56 |
+ $ sudo systemctl enable lxc-docker |
| ... | ... |
@@ -43,7 +43,7 @@ use flags to pull in the proper dependencies of the major storage |
| 43 | 43 |
drivers, with the "device-mapper" use flag being enabled by default, |
| 44 | 44 |
since that is the simplest installation path. |
| 45 | 45 |
|
| 46 |
- sudo emerge -av app-emulation/docker |
|
| 46 |
+ $ sudo emerge -av app-emulation/docker |
|
| 47 | 47 |
|
| 48 | 48 |
If any issues arise from this ebuild or the resulting binary, including |
| 49 | 49 |
and especially missing kernel configuration flags and/or dependencies, |
| ... | ... |
@@ -61,18 +61,18 @@ and/or AUFS, depending on the storage driver you`ve decided to use). |
| 61 | 61 |
|
| 62 | 62 |
To start the docker daemon: |
| 63 | 63 |
|
| 64 |
- sudo /etc/init.d/docker start |
|
| 64 |
+ $ sudo /etc/init.d/docker start |
|
| 65 | 65 |
|
| 66 | 66 |
To start on system boot: |
| 67 | 67 |
|
| 68 |
- sudo rc-update add docker default |
|
| 68 |
+ $ sudo rc-update add docker default |
|
| 69 | 69 |
|
| 70 | 70 |
### systemd |
| 71 | 71 |
|
| 72 | 72 |
To start the docker daemon: |
| 73 | 73 |
|
| 74 |
- sudo systemctl start docker.service |
|
| 74 |
+ $ sudo systemctl start docker.service |
|
| 75 | 75 |
|
| 76 | 76 |
To start on system boot: |
| 77 | 77 |
|
| 78 |
- sudo systemctl enable docker.service |
|
| 78 |
+ $ sudo systemctl enable docker.service |
| ... | ... |
@@ -45,19 +45,19 @@ page_keywords: Docker, Docker documentation, installation, google, Google Comput |
| 45 | 45 |
<!-- --> |
| 46 | 46 |
|
| 47 | 47 |
$ gcutil ssh docker-playground |
| 48 |
- docker-playground:~$ |
|
| 48 |
+ $ docker-playground:~$ |
|
| 49 | 49 |
|
| 50 | 50 |
5. Install the latest Docker release and configure it to start when the |
| 51 | 51 |
instance boots: |
| 52 | 52 |
|
| 53 | 53 |
<!-- --> |
| 54 | 54 |
|
| 55 |
- docker-playground:~$ curl get.docker.io | bash |
|
| 56 |
- docker-playground:~$ sudo update-rc.d docker defaults |
|
| 55 |
+ $ docker-playground:~$ curl get.docker.io | bash |
|
| 56 |
+ $ docker-playground:~$ sudo update-rc.d docker defaults |
|
| 57 | 57 |
|
| 58 | 58 |
6. Start a new container: |
| 59 | 59 |
|
| 60 | 60 |
<!-- --> |
| 61 | 61 |
|
| 62 |
- docker-playground:~$ sudo docker run busybox echo 'docker on GCE \o/' |
|
| 63 |
- docker on GCE \o/ |
|
| 62 |
+ $ docker-playground:~$ sudo docker run busybox echo 'docker on GCE \o/' |
|
| 63 |
+ $ docker on GCE \o/ |
| ... | ... |
@@ -40,7 +40,7 @@ image that is used for the job. |
| 40 | 40 |
If you are using Homebrew on your machine, simply run the following |
| 41 | 41 |
command to install `boot2docker`: |
| 42 | 42 |
|
| 43 |
- brew install boot2docker |
|
| 43 |
+ $ brew install boot2docker |
|
| 44 | 44 |
|
| 45 | 45 |
#### Manual installation |
| 46 | 46 |
|
| ... | ... |
@@ -49,13 +49,13 @@ Open up a new terminal window, if you have not already. |
| 49 | 49 |
Run the following commands to get boot2docker: |
| 50 | 50 |
|
| 51 | 51 |
# Enter the installation directory |
| 52 |
- cd ~/bin |
|
| 52 |
+ $ cd ~/bin |
|
| 53 | 53 |
|
| 54 | 54 |
# Get the file |
| 55 |
- curl https://raw.github.com/boot2docker/boot2docker/master/boot2docker > boot2docker |
|
| 55 |
+ $ curl https://raw.github.com/boot2docker/boot2docker/master/boot2docker > boot2docker |
|
| 56 | 56 |
|
| 57 | 57 |
# Mark it executable |
| 58 |
- chmod +x boot2docker |
|
| 58 |
+ $ chmod +x boot2docker |
|
| 59 | 59 |
|
| 60 | 60 |
### Docker OS X Client |
| 61 | 61 |
|
| ... | ... |
@@ -67,25 +67,25 @@ The `docker` daemon is accessed using the |
| 67 | 67 |
Run the following command to install the `docker` |
| 68 | 68 |
client: |
| 69 | 69 |
|
| 70 |
- brew install docker |
|
| 70 |
+ $ brew install docker |
|
| 71 | 71 |
|
| 72 | 72 |
#### Manual installation |
| 73 | 73 |
|
| 74 | 74 |
Run the following commands to get it downloaded and set up: |
| 75 | 75 |
|
| 76 | 76 |
# Get the docker client file |
| 77 |
- DIR=$(mktemp -d ${TMPDIR:-/tmp}/dockerdl.XXXXXXX) && \
|
|
| 78 |
- curl -f -o $DIR/ld.tgz https://get.docker.io/builds/Darwin/x86_64/docker-latest.tgz && \ |
|
| 79 |
- gunzip $DIR/ld.tgz && \ |
|
| 80 |
- tar xvf $DIR/ld.tar -C $DIR/ && \ |
|
| 81 |
- cp $DIR/usr/local/bin/docker ./docker |
|
| 77 |
+ $ DIR=$(mktemp -d ${TMPDIR:-/tmp}/dockerdl.XXXXXXX) && \
|
|
| 78 |
+ $ curl -f -o $DIR/ld.tgz https://get.docker.io/builds/Darwin/x86_64/docker-latest.tgz && \ |
|
| 79 |
+ $ gunzip $DIR/ld.tgz && \ |
|
| 80 |
+ $ tar xvf $DIR/ld.tar -C $DIR/ && \ |
|
| 81 |
+ $ cp $DIR/usr/local/bin/docker ./docker |
|
| 82 | 82 |
|
| 83 | 83 |
# Set the environment variable for the docker daemon |
| 84 |
- export DOCKER_HOST=tcp://127.0.0.1:4243 |
|
| 84 |
+ $ export DOCKER_HOST=tcp://127.0.0.1:4243 |
|
| 85 | 85 |
|
| 86 | 86 |
# Copy the executable file |
| 87 |
- sudo mkdir -p /usr/local/bin |
|
| 88 |
- sudo cp docker /usr/local/bin/ |
|
| 87 |
+ $ sudo mkdir -p /usr/local/bin |
|
| 88 |
+ $ sudo cp docker /usr/local/bin/ |
|
| 89 | 89 |
|
| 90 | 90 |
And that's it! Let's check out how to use it. |
| 91 | 91 |
|
| ... | ... |
@@ -97,13 +97,13 @@ Inside the `~/bin` directory, run the following |
| 97 | 97 |
commands: |
| 98 | 98 |
|
| 99 | 99 |
# Initiate the VM |
| 100 |
- ./boot2docker init |
|
| 100 |
+ $ ./boot2docker init |
|
| 101 | 101 |
|
| 102 | 102 |
# Run the VM (the docker daemon) |
| 103 |
- ./boot2docker up |
|
| 103 |
+ $ ./boot2docker up |
|
| 104 | 104 |
|
| 105 | 105 |
# To see all available commands: |
| 106 |
- ./boot2docker |
|
| 106 |
+ $ ./boot2docker |
|
| 107 | 107 |
|
| 108 | 108 |
# Usage ./boot2docker {init|start|up|pause|stop|restart|status|info|delete|ssh|download}
|
| 109 | 109 |
|
| ... | ... |
@@ -113,7 +113,7 @@ Once the VM with the `docker` daemon is up, you can |
| 113 | 113 |
use the `docker` client just like any other |
| 114 | 114 |
application. |
| 115 | 115 |
|
| 116 |
- docker version |
|
| 116 |
+ $ docker version |
|
| 117 | 117 |
# Client version: 0.7.6 |
| 118 | 118 |
# Go version (client): go1.2 |
| 119 | 119 |
# Git commit (client): bc3b2ec |
| ... | ... |
@@ -137,7 +137,7 @@ interact with our containers as if they were running locally: |
| 137 | 137 |
|
| 138 | 138 |
If you feel the need to connect to the VM, you can simply run: |
| 139 | 139 |
|
| 140 |
- ./boot2docker ssh |
|
| 140 |
+ $ ./boot2docker ssh |
|
| 141 | 141 |
|
| 142 | 142 |
# User: docker |
| 143 | 143 |
# Pwd: tcuser |
| ... | ... |
@@ -154,7 +154,7 @@ See the GitHub page for |
| 154 | 154 |
|
| 155 | 155 |
### If SSH complains about keys: |
| 156 | 156 |
|
| 157 |
- ssh-keygen -R '[localhost]:2022' |
|
| 157 |
+ $ ssh-keygen -R '[localhost]:2022' |
|
| 158 | 158 |
|
| 159 | 159 |
### Upgrading to a newer release of boot2docker |
| 160 | 160 |
|
| ... | ... |
@@ -162,9 +162,9 @@ To upgrade an initialised VM, you can use the following 3 commands. Your |
| 162 | 162 |
persistence disk will not be changed, so you won't lose your images and |
| 163 | 163 |
containers: |
| 164 | 164 |
|
| 165 |
- ./boot2docker stop |
|
| 166 |
- ./boot2docker download |
|
| 167 |
- ./boot2docker start |
|
| 165 |
+ $ ./boot2docker stop |
|
| 166 |
+ $ ./boot2docker download |
|
| 167 |
+ $ ./boot2docker start |
|
| 168 | 168 |
|
| 169 | 169 |
### About the way Docker works on Mac OS X: |
| 170 | 170 |
|
| ... | ... |
@@ -30,14 +30,14 @@ To proceed with Docker installation please add the right Virtualization |
| 30 | 30 |
repository. |
| 31 | 31 |
|
| 32 | 32 |
# openSUSE 12.3 |
| 33 |
- sudo zypper ar -f http://download.opensuse.org/repositories/Virtualization/openSUSE_12.3/ Virtualization |
|
| 33 |
+ $ sudo zypper ar -f http://download.opensuse.org/repositories/Virtualization/openSUSE_12.3/ Virtualization |
|
| 34 | 34 |
|
| 35 | 35 |
# openSUSE 13.1 |
| 36 |
- sudo zypper ar -f http://download.opensuse.org/repositories/Virtualization/openSUSE_13.1/ Virtualization |
|
| 36 |
+ $ sudo zypper ar -f http://download.opensuse.org/repositories/Virtualization/openSUSE_13.1/ Virtualization |
|
| 37 | 37 |
|
| 38 | 38 |
Install the Docker package. |
| 39 | 39 |
|
| 40 |
- sudo zypper in docker |
|
| 40 |
+ $ sudo zypper in docker |
|
| 41 | 41 |
|
| 42 | 42 |
It's also possible to install Docker using openSUSE's1-click install. |
| 43 | 43 |
Just visit [this](http://software.opensuse.org/package/docker) page, |
| ... | ... |
@@ -47,17 +47,17 @@ the docker package. |
| 47 | 47 |
|
| 48 | 48 |
Now that it's installed, let's start the Docker daemon. |
| 49 | 49 |
|
| 50 |
- sudo systemctl start docker |
|
| 50 |
+ $ sudo systemctl start docker |
|
| 51 | 51 |
|
| 52 | 52 |
If we want Docker to start at boot, we should also: |
| 53 | 53 |
|
| 54 |
- sudo systemctl enable docker |
|
| 54 |
+ $ sudo systemctl enable docker |
|
| 55 | 55 |
|
| 56 | 56 |
The docker package creates a new group named docker. Users, other than |
| 57 | 57 |
root user, need to be part of this group in order to interact with the |
| 58 | 58 |
Docker daemon. |
| 59 | 59 |
|
| 60 |
- sudo usermod -G docker <username> |
|
| 60 |
+ $ sudo usermod -G docker <username> |
|
| 61 | 61 |
|
| 62 | 62 |
**Done!** |
| 63 | 63 |
Now continue with the [*Hello World*]( |
| ... | ... |
@@ -29,16 +29,16 @@ you will need to set the kernel manually. |
| 29 | 29 |
**Do not attempt this on a production machine!** |
| 30 | 30 |
|
| 31 | 31 |
# update apt |
| 32 |
- apt-get update |
|
| 32 |
+ $ apt-get update |
|
| 33 | 33 |
|
| 34 | 34 |
# install the new kernel |
| 35 |
- apt-get install linux-generic-lts-raring |
|
| 35 |
+ $ apt-get install linux-generic-lts-raring |
|
| 36 | 36 |
|
| 37 | 37 |
Great, now you have the kernel installed in `/boot/`, next you need to |
| 38 | 38 |
make it boot next time. |
| 39 | 39 |
|
| 40 | 40 |
# find the exact names |
| 41 |
- find /boot/ -name '*3.8*' |
|
| 41 |
+ $ find /boot/ -name '*3.8*' |
|
| 42 | 42 |
|
| 43 | 43 |
# this should return some results |
| 44 | 44 |
|
| ... | ... |
@@ -51,7 +51,7 @@ the right files. |
| 51 | 51 |
Take special care to double check the kernel and initrd entries. |
| 52 | 52 |
|
| 53 | 53 |
# now edit /boot/grub/menu.lst |
| 54 |
- vi /boot/grub/menu.lst |
|
| 54 |
+ $ vi /boot/grub/menu.lst |
|
| 55 | 55 |
|
| 56 | 56 |
It will probably look something like this: |
| 57 | 57 |
|
| ... | ... |
@@ -78,7 +78,7 @@ Reboot the server (either via command line or console) |
| 78 | 78 |
|
| 79 | 79 |
Verify the kernel was updated |
| 80 | 80 |
|
| 81 |
- uname -a |
|
| 81 |
+ $ uname -a |
|
| 82 | 82 |
# Linux docker-12-04 3.8.0-19-generic #30~precise1-Ubuntu SMP Wed May 1 22:26:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux |
| 83 | 83 |
|
| 84 | 84 |
# nice! 3.8. |
| ... | ... |
@@ -49,23 +49,23 @@ To proceed with `docker-io` installation, please remove `docker` first. |
| 49 | 49 |
Next, let's install the `docker-io` package which |
| 50 | 50 |
will install Docker on our host. |
| 51 | 51 |
|
| 52 |
- sudo yum -y install docker-io |
|
| 52 |
+ $ sudo yum -y install docker-io |
|
| 53 | 53 |
|
| 54 | 54 |
To update the `docker-io` package |
| 55 | 55 |
|
| 56 |
- sudo yum -y update docker-io |
|
| 56 |
+ $ sudo yum -y update docker-io |
|
| 57 | 57 |
|
| 58 | 58 |
Now that it's installed, let's start the Docker daemon. |
| 59 | 59 |
|
| 60 |
- sudo service docker start |
|
| 60 |
+ $ sudo service docker start |
|
| 61 | 61 |
|
| 62 | 62 |
If we want Docker to start at boot, we should also: |
| 63 | 63 |
|
| 64 |
- sudo chkconfig docker on |
|
| 64 |
+ $ sudo chkconfig docker on |
|
| 65 | 65 |
|
| 66 | 66 |
Now let's verify that Docker is working. |
| 67 | 67 |
|
| 68 |
- sudo docker run -i -t fedora /bin/bash |
|
| 68 |
+ $ sudo docker run -i -t fedora /bin/bash |
|
| 69 | 69 |
|
| 70 | 70 |
**Done!** |
| 71 | 71 |
Now continue with the [*Hello World*](/examples/hello_world/#hello-world) example. |
| ... | ... |
@@ -33,13 +33,13 @@ installs all its prerequisites from Ubuntu's repository. |
| 33 | 33 |
|
| 34 | 34 |
To install the latest Ubuntu package (may not be the latest Docker release): |
| 35 | 35 |
|
| 36 |
- sudo apt-get update |
|
| 37 |
- sudo apt-get install docker.io |
|
| 38 |
- sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker |
|
| 36 |
+ $ sudo apt-get update |
|
| 37 |
+ $ sudo apt-get install docker.io |
|
| 38 |
+ $ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker |
|
| 39 | 39 |
|
| 40 | 40 |
To verify that everything has worked as expected: |
| 41 | 41 |
|
| 42 |
- sudo docker run -i -t ubuntu /bin/bash |
|
| 42 |
+ $ sudo docker run -i -t ubuntu /bin/bash |
|
| 43 | 43 |
|
| 44 | 44 |
Which should download the `ubuntu` image, and then start `bash` in a container. |
| 45 | 45 |
|
| ... | ... |
@@ -61,11 +61,11 @@ VirtualBox guest additions. If you didn't install the headers for your |
| 61 | 61 |
kernel. But it is safer to include them if you're not sure. |
| 62 | 62 |
|
| 63 | 63 |
# install the backported kernel |
| 64 |
- sudo apt-get update |
|
| 65 |
- sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring |
|
| 64 |
+ $ sudo apt-get update |
|
| 65 |
+ $ sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring |
|
| 66 | 66 |
|
| 67 | 67 |
# reboot |
| 68 |
- sudo reboot |
|
| 68 |
+ $ sudo reboot |
|
| 69 | 69 |
|
| 70 | 70 |
### Installation |
| 71 | 71 |
|
| ... | ... |
@@ -90,7 +90,7 @@ should exist. If it doesn't, you need to install the package |
| 90 | 90 |
|
| 91 | 91 |
Then, add the Docker repository key to your local keychain. |
| 92 | 92 |
|
| 93 |
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 |
|
| 93 |
+ $ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 |
|
| 94 | 94 |
|
| 95 | 95 |
Add the Docker repository to your apt sources list, update and install |
| 96 | 96 |
the `lxc-docker` package. |
| ... | ... |
@@ -98,21 +98,21 @@ the `lxc-docker` package. |
| 98 | 98 |
*You may receive a warning that the package isn't trusted. Answer yes to |
| 99 | 99 |
continue installation.* |
| 100 | 100 |
|
| 101 |
- sudo sh -c "echo deb https://get.docker.io/ubuntu docker main\ |
|
| 101 |
+ $ sudo sh -c "echo deb https://get.docker.io/ubuntu docker main\ |
|
| 102 | 102 |
> /etc/apt/sources.list.d/docker.list" |
| 103 |
- sudo apt-get update |
|
| 104 |
- sudo apt-get install lxc-docker |
|
| 103 |
+ $ sudo apt-get update |
|
| 104 |
+ $ sudo apt-get install lxc-docker |
|
| 105 | 105 |
|
| 106 | 106 |
> **Note**: |
| 107 | 107 |
> |
| 108 | 108 |
> There is also a simple `curl` script available to help with this process. |
| 109 | 109 |
> |
| 110 |
-> curl -s https://get.docker.io/ubuntu/ | sudo sh |
|
| 110 |
+> $ curl -s https://get.docker.io/ubuntu/ | sudo sh |
|
| 111 | 111 |
|
| 112 | 112 |
Now verify that the installation has worked by downloading the |
| 113 | 113 |
`ubuntu` image and launching a container. |
| 114 | 114 |
|
| 115 |
- sudo docker run -i -t ubuntu /bin/bash |
|
| 115 |
+ $ sudo docker run -i -t ubuntu /bin/bash |
|
| 116 | 116 |
|
| 117 | 117 |
Type `exit` to exit |
| 118 | 118 |
|
| ... | ... |
@@ -134,8 +134,8 @@ available as a driver and we recommend using it if you can. |
| 134 | 134 |
|
| 135 | 135 |
To make sure AUFS is installed, run the following commands: |
| 136 | 136 |
|
| 137 |
- sudo apt-get update |
|
| 138 |
- sudo apt-get install linux-image-extra-`uname -r` |
|
| 137 |
+ $ sudo apt-get update |
|
| 138 |
+ $ sudo apt-get install linux-image-extra-`uname -r` |
|
| 139 | 139 |
|
| 140 | 140 |
### Installation |
| 141 | 141 |
|
| ... | ... |
@@ -147,20 +147,20 @@ Docker is available as a Debian package, which makes installation easy. |
| 147 | 147 |
|
| 148 | 148 |
First add the Docker repository key to your local keychain. |
| 149 | 149 |
|
| 150 |
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 |
|
| 150 |
+ $ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 |
|
| 151 | 151 |
|
| 152 | 152 |
Add the Docker repository to your apt sources list, update and install |
| 153 | 153 |
the `lxc-docker` package. |
| 154 | 154 |
|
| 155 |
- sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\ |
|
| 155 |
+ $ sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\ |
|
| 156 | 156 |
> /etc/apt/sources.list.d/docker.list" |
| 157 |
- sudo apt-get update |
|
| 158 |
- sudo apt-get install lxc-docker |
|
| 157 |
+ $ sudo apt-get update |
|
| 158 |
+ $ sudo apt-get install lxc-docker |
|
| 159 | 159 |
|
| 160 | 160 |
Now verify that the installation has worked by downloading the |
| 161 | 161 |
`ubuntu` image and launching a container. |
| 162 | 162 |
|
| 163 |
- sudo docker run -i -t ubuntu /bin/bash |
|
| 163 |
+ $ sudo docker run -i -t ubuntu /bin/bash |
|
| 164 | 164 |
|
| 165 | 165 |
Type `exit` to exit |
| 166 | 166 |
|
| ... | ... |
@@ -194,16 +194,16 @@ than `docker` should own the Unix socket with the |
| 194 | 194 |
**Example:** |
| 195 | 195 |
|
| 196 | 196 |
# Add the docker group if it doesn't already exist. |
| 197 |
- sudo groupadd docker |
|
| 197 |
+ $ sudo groupadd docker |
|
| 198 | 198 |
|
| 199 | 199 |
# Add the connected user "${USER}" to the docker group.
|
| 200 | 200 |
# Change the user name to match your preferred user. |
| 201 | 201 |
# You may have to logout and log back in again for |
| 202 | 202 |
# this to take effect. |
| 203 |
- sudo gpasswd -a ${USER} docker
|
|
| 203 |
+ $ sudo gpasswd -a ${USER} docker
|
|
| 204 | 204 |
|
| 205 | 205 |
# Restart the Docker daemon. |
| 206 |
- sudo service docker restart |
|
| 206 |
+ $ sudo service docker restart |
|
| 207 | 207 |
|
| 208 | 208 |
### Upgrade |
| 209 | 209 |
|
| ... | ... |
@@ -211,28 +211,28 @@ To install the latest version of docker, use the standard |
| 211 | 211 |
`apt-get` method: |
| 212 | 212 |
|
| 213 | 213 |
# update your sources list |
| 214 |
- sudo apt-get update |
|
| 214 |
+ $ sudo apt-get update |
|
| 215 | 215 |
|
| 216 | 216 |
# install the latest |
| 217 |
- sudo apt-get install lxc-docker |
|
| 217 |
+ $ sudo apt-get install lxc-docker |
|
| 218 | 218 |
|
| 219 | 219 |
## Memory and Swap Accounting |
| 220 | 220 |
|
| 221 | 221 |
If you want to enable memory and swap accounting, you must add the |
| 222 | 222 |
following command-line parameters to your kernel: |
| 223 | 223 |
|
| 224 |
- cgroup_enable=memory swapaccount=1 |
|
| 224 |
+ $ cgroup_enable=memory swapaccount=1 |
|
| 225 | 225 |
|
| 226 | 226 |
On systems using GRUB (which is the default for Ubuntu), you can add |
| 227 | 227 |
those parameters by editing `/etc/default/grub` and |
| 228 | 228 |
extending `GRUB_CMDLINE_LINUX`. Look for the |
| 229 | 229 |
following line: |
| 230 | 230 |
|
| 231 |
- GRUB_CMDLINE_LINUX="" |
|
| 231 |
+ $ GRUB_CMDLINE_LINUX="" |
|
| 232 | 232 |
|
| 233 | 233 |
And replace it by the following one: |
| 234 | 234 |
|
| 235 |
- GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1" |
|
| 235 |
+ $ GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1" |
|
| 236 | 236 |
|
| 237 | 237 |
Then run `sudo update-grub`, and reboot. |
| 238 | 238 |
|
| ... | ... |
@@ -247,7 +247,7 @@ On Linux Mint, the `cgroup-lite` package is not |
| 247 | 247 |
installed by default. Before Docker will work correctly, you will need |
| 248 | 248 |
to install this via: |
| 249 | 249 |
|
| 250 |
- sudo apt-get update && sudo apt-get install cgroup-lite |
|
| 250 |
+ $ sudo apt-get update && sudo apt-get install cgroup-lite |
|
| 251 | 251 |
|
| 252 | 252 |
## Docker and UFW |
| 253 | 253 |
|
| ... | ... |
@@ -255,22 +255,22 @@ Docker uses a bridge to manage container networking. By default, UFW |
| 255 | 255 |
drops all forwarding traffic. As a result you will need to enable UFW |
| 256 | 256 |
forwarding: |
| 257 | 257 |
|
| 258 |
- sudo nano /etc/default/ufw |
|
| 259 |
- ---- |
|
| 258 |
+ $ sudo nano /etc/default/ufw |
|
| 259 |
+ |
|
| 260 | 260 |
# Change: |
| 261 | 261 |
# DEFAULT_FORWARD_POLICY="DROP" |
| 262 | 262 |
# to |
| 263 |
- DEFAULT_FORWARD_POLICY="ACCEPT" |
|
| 263 |
+ $ DEFAULT_FORWARD_POLICY="ACCEPT" |
|
| 264 | 264 |
|
| 265 | 265 |
Then reload UFW: |
| 266 | 266 |
|
| 267 |
- sudo ufw reload |
|
| 267 |
+ $ sudo ufw reload |
|
| 268 | 268 |
|
| 269 | 269 |
UFW's default set of rules denies all incoming traffic. If you want to |
| 270 | 270 |
be able to reach your containers from another host then you should allow |
| 271 | 271 |
incoming connections on the Docker port (default 4243): |
| 272 | 272 |
|
| 273 |
- sudo ufw allow 4243/tcp |
|
| 273 |
+ $ sudo ufw allow 4243/tcp |
|
| 274 | 274 |
|
| 275 | 275 |
## Docker and local DNS server warnings |
| 276 | 276 |
|
| ... | ... |
@@ -290,16 +290,16 @@ nameserver and Docker will default to using an external nameserver. |
| 290 | 290 |
This can be worked around by specifying a DNS server to be used by the |
| 291 | 291 |
Docker daemon for the containers: |
| 292 | 292 |
|
| 293 |
- sudo nano /etc/default/docker |
|
| 293 |
+ $ sudo nano /etc/default/docker |
|
| 294 | 294 |
--- |
| 295 | 295 |
# Add: |
| 296 |
- DOCKER_OPTS="--dns 8.8.8.8" |
|
| 296 |
+ $ docker_OPTS="--dns 8.8.8.8" |
|
| 297 | 297 |
# 8.8.8.8 could be replaced with a local DNS server, such as 192.168.1.1 |
| 298 | 298 |
# multiple DNS servers can be specified: --dns 8.8.8.8 --dns 192.168.1.1 |
| 299 | 299 |
|
| 300 | 300 |
The Docker daemon has to be restarted: |
| 301 | 301 |
|
| 302 |
- sudo restart docker |
|
| 302 |
+ $ sudo restart docker |
|
| 303 | 303 |
|
| 304 | 304 |
> **Warning**: |
| 305 | 305 |
> If you're doing this on a laptop which connects to various networks, |
| ... | ... |
@@ -308,7 +308,7 @@ The Docker daemon has to be restarted: |
| 308 | 308 |
An alternative solution involves disabling dnsmasq in NetworkManager by |
| 309 | 309 |
following these steps: |
| 310 | 310 |
|
| 311 |
- sudo nano /etc/NetworkManager/NetworkManager.conf |
|
| 311 |
+ $ sudo nano /etc/NetworkManager/NetworkManager.conf |
|
| 312 | 312 |
---- |
| 313 | 313 |
# Change: |
| 314 | 314 |
dns=dnsmasq |
| ... | ... |
@@ -317,8 +317,8 @@ following these steps: |
| 317 | 317 |
|
| 318 | 318 |
NetworkManager and Docker need to be restarted afterwards: |
| 319 | 319 |
|
| 320 |
- sudo restart network-manager |
|
| 321 |
- sudo restart docker |
|
| 320 |
+ $ sudo restart network-manager |
|
| 321 |
+ $ sudo restart docker |
|
| 322 | 322 |
|
| 323 | 323 |
> **Warning**: This might make DNS resolution slower on some networks. |
| 324 | 324 |
|
| ... | ... |
@@ -336,7 +336,7 @@ Substitute `http://mirror.yandex.ru/mirrors/docker/` for |
| 336 | 336 |
`http://get.docker.io/ubuntu` in the instructions above. |
| 337 | 337 |
For example: |
| 338 | 338 |
|
| 339 |
- sudo sh -c "echo deb http://mirror.yandex.ru/mirrors/docker/ docker main\ |
|
| 339 |
+ $ sudo sh -c "echo deb http://mirror.yandex.ru/mirrors/docker/ docker main\ |
|
| 340 | 340 |
> /etc/apt/sources.list.d/docker.list" |
| 341 |
- sudo apt-get update |
|
| 342 |
- sudo apt-get install lxc-docker |
|
| 341 |
+ $ sudo apt-get update |
|
| 342 |
+ $ sudo apt-get install lxc-docker |
| ... | ... |
@@ -60,7 +60,7 @@ The `docker` client usage consists of passing a chain of arguments: |
| 60 | 60 |
|
| 61 | 61 |
# Usage: [sudo] docker [option] [command] [arguments] .. |
| 62 | 62 |
# Example: |
| 63 |
- docker run -i -t ubuntu /bin/bash |
|
| 63 |
+ $ docker run -i -t ubuntu /bin/bash |
|
| 64 | 64 |
|
| 65 | 65 |
### Our first Docker command |
| 66 | 66 |
|
| ... | ... |
@@ -70,7 +70,7 @@ version` command. |
| 70 | 70 |
|
| 71 | 71 |
# Usage: [sudo] docker version |
| 72 | 72 |
# Example: |
| 73 |
- docker version |
|
| 73 |
+ $ docker version |
|
| 74 | 74 |
|
| 75 | 75 |
This command will not only provide you the version of Docker client you |
| 76 | 76 |
are using, but also the version of Go (the programming language powering |
| ... | ... |
@@ -97,7 +97,7 @@ binary: |
| 97 | 97 |
|
| 98 | 98 |
# Usage: [sudo] docker |
| 99 | 99 |
# Example: |
| 100 |
- docker |
|
| 100 |
+ $ docker |
|
| 101 | 101 |
|
| 102 | 102 |
You will get an output with all currently available commands. |
| 103 | 103 |
|
| ... | ... |
@@ -116,12 +116,12 @@ Try typing Docker followed with a `[command]` to see the instructions: |
| 116 | 116 |
|
| 117 | 117 |
# Usage: [sudo] docker [command] [--help] |
| 118 | 118 |
# Example: |
| 119 |
- docker attach |
|
| 119 |
+ $ docker attach |
|
| 120 | 120 |
Help outputs . . . |
| 121 | 121 |
|
| 122 | 122 |
Or you can pass the `--help` flag to the `docker` binary. |
| 123 | 123 |
|
| 124 |
- docker images --help |
|
| 124 |
+ $ docker images --help |
|
| 125 | 125 |
|
| 126 | 126 |
You will get an output with all available options: |
| 127 | 127 |
|
| ... | ... |
@@ -156,12 +156,12 @@ image is constructed. |
| 156 | 156 |
|
| 157 | 157 |
# Usage: [sudo] docker search [image name] |
| 158 | 158 |
# Example: |
| 159 |
- docker search nginx |
|
| 159 |
+ $ docker search nginx |
|
| 160 | 160 |
|
| 161 | 161 |
NAME DESCRIPTION STARS OFFICIAL TRUSTED |
| 162 |
- dockerfile/nginx Trusted Nginx (http://nginx.org/) Build 6 [OK] |
|
| 162 |
+ $ dockerfile/nginx Trusted Nginx (http://nginx.org/) Build 6 [OK] |
|
| 163 | 163 |
paintedfox/nginx-php5 A docker image for running Nginx with PHP5. 3 [OK] |
| 164 |
- dockerfiles/django-uwsgi-nginx Dockerfile and configuration files to buil... 2 [OK] |
|
| 164 |
+ $ dockerfiles/django-uwsgi-nginx dockerfile and configuration files to buil... 2 [OK] |
|
| 165 | 165 |
. . . |
| 166 | 166 |
|
| 167 | 167 |
> **Note:** To learn more about trusted builds, check out [this]( |
| ... | ... |
@@ -174,7 +174,7 @@ Downloading a Docker image is called *pulling*. To do this we hence use the |
| 174 | 174 |
|
| 175 | 175 |
# Usage: [sudo] docker pull [image name] |
| 176 | 176 |
# Example: |
| 177 |
- docker pull dockerfile/nginx |
|
| 177 |
+ $ docker pull dockerfile/nginx |
|
| 178 | 178 |
|
| 179 | 179 |
Pulling repository dockerfile/nginx |
| 180 | 180 |
0ade68db1d05: Pulling dependent layers |
| ... | ... |
@@ -193,12 +193,12 @@ In order to get a full list of available images, you can use the |
| 193 | 193 |
|
| 194 | 194 |
# Usage: [sudo] docker images |
| 195 | 195 |
# Example: |
| 196 |
- docker images |
|
| 196 |
+ $ docker images |
|
| 197 | 197 |
|
| 198 | 198 |
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
| 199 | 199 |
myUserName/nginx latest a0d6c70867d2 41 seconds ago 578.8 MB |
| 200 | 200 |
nginx latest 173c2dd28ab2 3 minutes ago 578.8 MB |
| 201 |
- dockerfile/nginx latest 0ade68db1d05 3 weeks ago 578.8 MB |
|
| 201 |
+ $ dockerfile/nginx latest 0ade68db1d05 3 weeks ago 578.8 MB |
|
| 202 | 202 |
|
| 203 | 203 |
## Working with containers |
| 204 | 204 |
|
| ... | ... |
@@ -215,7 +215,7 @@ The easiest way to create a new container is to *run* one from an image. |
| 215 | 215 |
|
| 216 | 216 |
# Usage: [sudo] docker run [arguments] .. |
| 217 | 217 |
# Example: |
| 218 |
- docker run -d --name nginx_web nginx /usr/sbin/nginx |
|
| 218 |
+ $ docker run -d --name nginx_web nginx /usr/sbin/nginx |
|
| 219 | 219 |
|
| 220 | 220 |
This will create a new container from an image called `nginx` which will |
| 221 | 221 |
launch the command `/usr/sbin/nginx` when the container is run. We've |
| ... | ... |
@@ -242,10 +242,10 @@ both running and stopped. |
| 242 | 242 |
|
| 243 | 243 |
# Usage: [sudo] docker ps [-a] |
| 244 | 244 |
# Example: |
| 245 |
- docker ps |
|
| 245 |
+ $ docker ps |
|
| 246 | 246 |
|
| 247 | 247 |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
| 248 |
- 842a50a13032 dockerfile/nginx:latest nginx 35 minutes ago Up 30 minutes 0.0.0.0:80->80/tcp nginx_web |
|
| 248 |
+ 842a50a13032 $ dockerfile/nginx:latest nginx 35 minutes ago Up 30 minutes 0.0.0.0:80->80/tcp nginx_web |
|
| 249 | 249 |
|
| 250 | 250 |
### Stopping a container |
| 251 | 251 |
|
| ... | ... |
@@ -254,7 +254,7 @@ end the active process. |
| 254 | 254 |
|
| 255 | 255 |
# Usage: [sudo] docker stop [container ID] |
| 256 | 256 |
# Example: |
| 257 |
- docker stop nginx_web |
|
| 257 |
+ $ docker stop nginx_web |
|
| 258 | 258 |
nginx_web |
| 259 | 259 |
|
| 260 | 260 |
If the `docker stop` command succeeds it will return the name of |
| ... | ... |
@@ -266,7 +266,7 @@ Stopped containers can be started again. |
| 266 | 266 |
|
| 267 | 267 |
# Usage: [sudo] docker start [container ID] |
| 268 | 268 |
# Example: |
| 269 |
- docker start nginx_web |
|
| 269 |
+ $ docker start nginx_web |
|
| 270 | 270 |
nginx_web |
| 271 | 271 |
|
| 272 | 272 |
If the `docker start` command succeeds it will return the name of the |
| ... | ... |
@@ -358,7 +358,7 @@ Docker uses the `Dockerfile` to build images. The build process is initiated by |
| 358 | 358 |
# Use the Dockerfile at the current location |
| 359 | 359 |
# Usage: [sudo] docker build . |
| 360 | 360 |
# Example: |
| 361 |
- docker build -t="my_nginx_image" . |
|
| 361 |
+ $ docker build -t="my_nginx_image" . |
|
| 362 | 362 |
|
| 363 | 363 |
Uploading context 25.09 kB |
| 364 | 364 |
Uploading context |
| ... | ... |
@@ -385,7 +385,7 @@ image, here `my_nginx_image`. |
| 385 | 385 |
|
| 386 | 386 |
We can see our new image using the `docker images` command. |
| 387 | 387 |
|
| 388 |
- docker images |
|
| 388 |
+ $ docker images |
|
| 389 | 389 |
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
| 390 | 390 |
my_nginx_img latest 626e92c5fab1 57 seconds ago 337.6 MB |
| 391 | 391 |
|
| ... | ... |
@@ -1127,4 +1127,4 @@ stdout and stderr on the same socket. This might change in the future. |
| 1127 | 1127 |
To enable cross origin requests to the remote api add the flag |
| 1128 | 1128 |
"–api-enable-cors" when running docker in daemon mode. |
| 1129 | 1129 |
|
| 1130 |
- docker -d -H="192.168.1.9:4243" --api-enable-cors |
|
| 1130 |
+ $ docker -d -H="192.168.1.9:4243" --api-enable-cors |
| ... | ... |
@@ -1134,4 +1134,4 @@ stdout and stderr on the same socket. This might change in the future. |
| 1134 | 1134 |
To enable cross origin requests to the remote api add the flag |
| 1135 | 1135 |
"–api-enable-cors" when running docker in daemon mode. |
| 1136 | 1136 |
|
| 1137 |
- docker -d -H="192.168.1.9:4243" --api-enable-cors |
|
| 1137 |
+ $ docker -d -H="192.168.1.9:4243" --api-enable-cors |
| ... | ... |
@@ -1236,4 +1236,4 @@ stdout and stderr on the same socket. This might change in the future. |
| 1236 | 1236 |
To enable cross origin requests to the remote api add the flag |
| 1237 | 1237 |
"–api-enable-cors" when running docker in daemon mode. |
| 1238 | 1238 |
|
| 1239 |
- docker -d -H="192.168.1.9:4243" --api-enable-cors |
|
| 1239 |
+ $ docker -d -H="192.168.1.9:4243" --api-enable-cors |
| ... | ... |
@@ -1230,4 +1230,4 @@ stdout and stderr on the same socket. This might change in the future. |
| 1230 | 1230 |
To enable cross origin requests to the remote api add the flag |
| 1231 | 1231 |
"–api-enable-cors" when running docker in daemon mode. |
| 1232 | 1232 |
|
| 1233 |
- docker -d -H="192.168.1.9:4243" --api-enable-cors |
|
| 1233 |
+ $ docker -d -H="192.168.1.9:4243" --api-enable-cors |
| ... | ... |
@@ -1276,4 +1276,4 @@ stdout and stderr on the same socket. This might change in the future. |
| 1276 | 1276 |
To enable cross origin requests to the remote api add the flag |
| 1277 | 1277 |
"–api-enable-cors" when running docker in daemon mode. |
| 1278 | 1278 |
|
| 1279 |
- docker -d -H="192.168.1.9:4243" --api-enable-cors |
|
| 1279 |
+ $ docker -d -H="192.168.1.9:4243" --api-enable-cors |
| ... | ... |
@@ -1297,4 +1297,4 @@ stdout and stderr on the same socket. This might change in the future. |
| 1297 | 1297 |
To enable cross origin requests to the remote api add the flag |
| 1298 | 1298 |
"–api-enable-cors" when running docker in daemon mode. |
| 1299 | 1299 |
|
| 1300 |
- docker -d -H="192.168.1.9:4243" --api-enable-cors |
|
| 1300 |
+ $ docker -d -H="192.168.1.9:4243" --api-enable-cors |
| ... | ... |
@@ -1337,4 +1337,4 @@ stdout and stderr on the same socket. This might change in the future. |
| 1337 | 1337 |
To enable cross origin requests to the remote api add the flag |
| 1338 | 1338 |
"–api-enable-cors" when running docker in daemon mode. |
| 1339 | 1339 |
|
| 1340 |
- docker -d -H="192.168.1.9:4243" --api-enable-cors |
|
| 1340 |
+ $ docker -d -H="192.168.1.9:4243" --api-enable-cors |
| ... | ... |
@@ -1313,4 +1313,4 @@ stdout and stderr on the same socket. This might change in the future. |
| 1313 | 1313 |
To enable cross origin requests to the remote api add the flag |
| 1314 | 1314 |
"–api-enable-cors" when running docker in daemon mode. |
| 1315 | 1315 |
|
| 1316 |
- docker -d -H="192.168.1.9:4243" --api-enable-cors |
|
| 1316 |
+ $ docker -d -H="192.168.1.9:4243" --api-enable-cors |
| ... | ... |
@@ -111,7 +111,7 @@ supports: |
| 111 | 111 |
|
| 112 | 112 |
It's possible to run: |
| 113 | 113 |
|
| 114 |
- docker pull https://<registry>/repositories/samalba/busybox |
|
| 114 |
+ $ docker pull https://<registry>/repositories/samalba/busybox |
|
| 115 | 115 |
|
| 116 | 116 |
In this case, Docker bypasses the Index. However the security is not |
| 117 | 117 |
guaranteed (in case Registry A is corrupted) because there won't be any |
| ... | ... |
@@ -18,7 +18,7 @@ This file will describe the steps to assemble the image. |
| 18 | 18 |
Then call `docker build` with the path of you source repository as argument |
| 19 | 19 |
(for example, `.`): |
| 20 | 20 |
|
| 21 |
- sudo docker build . |
|
| 21 |
+ $ sudo docker build . |
|
| 22 | 22 |
|
| 23 | 23 |
The path to the source repository defines where to find the *context* of |
| 24 | 24 |
the build. The build is run by the Docker daemon, not by the CLI, so the |
| ... | ... |
@@ -28,7 +28,7 @@ whole context must be transferred to the daemon. The Docker CLI reports |
| 28 | 28 |
You can specify a repository and tag at which to save the new image if |
| 29 | 29 |
the build succeeds: |
| 30 | 30 |
|
| 31 |
- sudo docker build -t shykes/myapp . |
|
| 31 |
+ $ sudo docker build -t shykes/myapp . |
|
| 32 | 32 |
|
| 33 | 33 |
The Docker daemon will run your steps one-by-one, committing the result |
| 34 | 34 |
to a new image if necessary, before finally outputting the ID of your |
| ... | ... |
@@ -35,11 +35,11 @@ will set the value to the opposite of the default value. |
| 35 | 35 |
|
| 36 | 36 |
Options like `-a=[]` indicate they can be specified multiple times: |
| 37 | 37 |
|
| 38 |
- docker run -a stdin -a stdout -a stderr -i -t ubuntu /bin/bash |
|
| 38 |
+ $ docker run -a stdin -a stdout -a stderr -i -t ubuntu /bin/bash |
|
| 39 | 39 |
|
| 40 | 40 |
Sometimes this can use a more complex value string, as for `-v`: |
| 41 | 41 |
|
| 42 |
- docker run -v /host:/container example/mysql |
|
| 42 |
+ $ docker run -v /host:/container example/mysql |
|
| 43 | 43 |
|
| 44 | 44 |
### Strings and Integers |
| 45 | 45 |
|
| ... | ... |
@@ -100,10 +100,10 @@ To use lxc as the execution driver, use `docker -d -e lxc`. |
| 100 | 100 |
The docker client will also honor the `DOCKER_HOST` environment variable to set |
| 101 | 101 |
the `-H` flag for the client. |
| 102 | 102 |
|
| 103 |
- docker -H tcp://0.0.0.0:4243 ps |
|
| 103 |
+ $ docker -H tcp://0.0.0.0:4243 ps |
|
| 104 | 104 |
# or |
| 105 |
- export DOCKER_HOST="tcp://0.0.0.0:4243" |
|
| 106 |
- docker ps |
|
| 105 |
+ $ export DOCKER_HOST="tcp://0.0.0.0:4243" |
|
| 106 |
+ $ docker ps |
|
| 107 | 107 |
# both are equal |
| 108 | 108 |
|
| 109 | 109 |
To run the daemon with [systemd socket activation]( |
| ... | ... |
@@ -448,7 +448,7 @@ by default. |
| 448 | 448 |
<none> <none> 77af4d6b9913 19 hours ago 1.089 GB |
| 449 | 449 |
committest latest b6fa739cedf5 19 hours ago 1.089 GB |
| 450 | 450 |
<none> <none> 78a85c484f71 19 hours ago 1.089 GB |
| 451 |
- docker latest 30557a29d5ab 20 hours ago 1.089 GB |
|
| 451 |
+ $ docker latest 30557a29d5ab 20 hours ago 1.089 GB |
|
| 452 | 452 |
<none> <none> 0124422dd9f9 20 hours ago 1.089 GB |
| 453 | 453 |
<none> <none> 18ad6fad3402 22 hours ago 1.082 GB |
| 454 | 454 |
<none> <none> f9f1e26352f0 23 hours ago 1.089 GB |
| ... | ... |
@@ -462,7 +462,7 @@ by default. |
| 462 | 462 |
<none> <none> 77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 1.089 GB |
| 463 | 463 |
committest latest b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 1.089 GB |
| 464 | 464 |
<none> <none> 78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921 19 hours ago 1.089 GB |
| 465 |
- docker latest 30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 1.089 GB |
|
| 465 |
+ $ docker latest 30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 1.089 GB |
|
| 466 | 466 |
<none> <none> 0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5 20 hours ago 1.089 GB |
| 467 | 467 |
<none> <none> 18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b 22 hours ago 1.082 GB |
| 468 | 468 |
<none> <none> f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a 23 hours ago 1.089 GB |
| ... | ... |
@@ -640,7 +640,7 @@ If you want to login to a private registry you can |
| 640 | 640 |
specify this by adding the server name. |
| 641 | 641 |
|
| 642 | 642 |
example: |
| 643 |
- docker login localhost:8080 |
|
| 643 |
+ $ docker login localhost:8080 |
|
| 644 | 644 |
|
| 645 | 645 |
## logs |
| 646 | 646 |
|
| ... | ... |
@@ -22,7 +22,7 @@ running containers, and so here we try to give more in-depth guidance. |
| 22 | 22 |
As you`ve seen in the [*Examples*](/examples/#example-list), the |
| 23 | 23 |
basic run command takes this form: |
| 24 | 24 |
|
| 25 |
- docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...] |
|
| 25 |
+ $ docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...] |
|
| 26 | 26 |
|
| 27 | 27 |
To learn how to interpret the types of `[OPTIONS]`, |
| 28 | 28 |
see [*Option types*](/commandline/cli/#cli-options). |
| ... | ... |
@@ -99,7 +99,7 @@ https://github.com/dotcloud/docker/blob/ |
| 99 | 99 |
of the three standard streams (`stdin`, `stdout`, `stderr`) you'd like to connect |
| 100 | 100 |
instead, as in: |
| 101 | 101 |
|
| 102 |
- docker run -a stdin -a stdout -i -t ubuntu /bin/bash |
|
| 102 |
+ $ docker run -a stdin -a stdout -i -t ubuntu /bin/bash |
|
| 103 | 103 |
|
| 104 | 104 |
For interactive processes (like a shell) you will typically want a tty as well as |
| 105 | 105 |
persistent standard input (`stdin`), so you'll use `-i -t` together in most |
| ... | ... |
@@ -233,7 +233,7 @@ Dockerfile instruction and how the operator can override that setting. |
| 233 | 233 |
Recall the optional `COMMAND` in the Docker |
| 234 | 234 |
commandline: |
| 235 | 235 |
|
| 236 |
- docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...] |
|
| 236 |
+ $ docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...] |
|
| 237 | 237 |
|
| 238 | 238 |
This command is optional because the person who created the `IMAGE` may have |
| 239 | 239 |
already provided a default `COMMAND` using the Dockerfile `CMD`. As the |
| ... | ... |
@@ -259,12 +259,12 @@ runtime by using a string to specify the new `ENTRYPOINT`. Here is an |
| 259 | 259 |
example of how to run a shell in a container that has been set up to |
| 260 | 260 |
automatically run something else (like `/usr/bin/redis-server`): |
| 261 | 261 |
|
| 262 |
- docker run -i -t --entrypoint /bin/bash example/redis |
|
| 262 |
+ $ docker run -i -t --entrypoint /bin/bash example/redis |
|
| 263 | 263 |
|
| 264 | 264 |
or two examples of how to pass more parameters to that ENTRYPOINT: |
| 265 | 265 |
|
| 266 |
- docker run -i -t --entrypoint /bin/bash example/redis -c ls -l |
|
| 267 |
- docker run -i -t --entrypoint /usr/bin/redis-cli example/redis --help |
|
| 266 |
+ $ docker run -i -t --entrypoint /bin/bash example/redis -c ls -l |
|
| 267 |
+ $ docker run -i -t --entrypoint /usr/bin/redis-cli example/redis --help |
|
| 268 | 268 |
|
| 269 | 269 |
## EXPOSE (Incoming Ports) |
| 270 | 270 |
|
| ... | ... |
@@ -335,7 +335,7 @@ container running Redis: |
| 335 | 335 |
# The redis-name container exposed port 6379 |
| 336 | 336 |
$ docker ps |
| 337 | 337 |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
| 338 |
- 4241164edf6f dockerfiles/redis:latest /redis-stable/src/re 5 seconds ago Up 4 seconds 6379/tcp redis-name |
|
| 338 |
+ 4241164edf6f $ dockerfiles/redis:latest /redis-stable/src/re 5 seconds ago Up 4 seconds 6379/tcp redis-name |
|
| 339 | 339 |
|
| 340 | 340 |
# Note that there are no public ports exposed since we didn᾿t use -p or -P |
| 341 | 341 |
$ docker port 4241164edf6f 6379 |
| ... | ... |
@@ -146,7 +146,7 @@ remote IP and port - in this case `192.168.1.52:6379`. |
| 146 | 146 |
# then to run it (on the host that has the real backend on it) |
| 147 | 147 |
# docker run -t -i -link redis:redis -name redis_ambassador -p 6379:6379 ambassador |
| 148 | 148 |
# on the remote host, you can set up another ambassador |
| 149 |
- # docker run -t -i -name redis_ambassador -expose 6379 sh |
|
| 149 |
+ # docker run -t -i -name redis_ambassador -expose 6379 sh |
|
| 150 | 150 |
|
| 151 | 151 |
FROM docker-ut |
| 152 | 152 |
MAINTAINER SvenDowideit@home.org.au |
| ... | ... |
@@ -10,7 +10,7 @@ This guide assumes you have a working installation of Docker. To check |
| 10 | 10 |
your Docker install, run the following command: |
| 11 | 11 |
|
| 12 | 12 |
# Check that you have a working install |
| 13 |
- docker info |
|
| 13 |
+ $ docker info |
|
| 14 | 14 |
|
| 15 | 15 |
If you get `docker: command not found` or something |
| 16 | 16 |
like `/var/lib/docker/repositories: permission denied` |
| ... | ... |
@@ -23,7 +23,7 @@ for installation instructions. |
| 23 | 23 |
## Download a pre-built image |
| 24 | 24 |
|
| 25 | 25 |
# Download an ubuntu image |
| 26 |
- sudo docker pull ubuntu |
|
| 26 |
+ $ sudo docker pull ubuntu |
|
| 27 | 27 |
|
| 28 | 28 |
This will find the `ubuntu` image by name on |
| 29 | 29 |
[*Docker.io*](../workingwithrepository/#find-public-images-on-dockerio) and |
| ... | ... |
@@ -46,7 +46,7 @@ cache. |
| 46 | 46 |
# To detach the tty without exiting the shell, |
| 47 | 47 |
# use the escape sequence Ctrl-p + Ctrl-q |
| 48 | 48 |
# note: This will continue to exist in a stopped state once exited (see "docker ps -a") |
| 49 |
- sudo docker run -i -t ubuntu /bin/bash |
|
| 49 |
+ $ sudo docker run -i -t ubuntu /bin/bash |
|
| 50 | 50 |
|
| 51 | 51 |
## Bind Docker to another host/port or a Unix socket |
| 52 | 52 |
|
| ... | ... |
@@ -87,70 +87,70 @@ when no `-H` was passed in. |
| 87 | 87 |
`host[:port]` or `:port` |
| 88 | 88 |
|
| 89 | 89 |
# Run docker in daemon mode |
| 90 |
- sudo <path to>/docker -H 0.0.0.0:5555 -d & |
|
| 90 |
+ $ sudo <path to>/docker -H 0.0.0.0:5555 -d & |
|
| 91 | 91 |
# Download an ubuntu image |
| 92 |
- sudo docker -H :5555 pull ubuntu |
|
| 92 |
+ $ sudo docker -H :5555 pull ubuntu |
|
| 93 | 93 |
|
| 94 | 94 |
You can use multiple `-H`, for example, if you want |
| 95 | 95 |
to listen on both TCP and a Unix socket |
| 96 | 96 |
|
| 97 | 97 |
# Run docker in daemon mode |
| 98 |
- sudo <path to>/docker -H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock -d & |
|
| 98 |
+ $ sudo <path to>/docker -H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock -d & |
|
| 99 | 99 |
# Download an ubuntu image, use default Unix socket |
| 100 |
- sudo docker pull ubuntu |
|
| 100 |
+ $ sudo docker pull ubuntu |
|
| 101 | 101 |
# OR use the TCP port |
| 102 |
- sudo docker -H tcp://127.0.0.1:4243 pull ubuntu |
|
| 102 |
+ $ sudo docker -H tcp://127.0.0.1:4243 pull ubuntu |
|
| 103 | 103 |
|
| 104 | 104 |
## Starting a long-running worker process |
| 105 | 105 |
|
| 106 | 106 |
# Start a very useful long-running process |
| 107 |
- JOB=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1; done") |
|
| 107 |
+ $ JOB=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1; done") |
|
| 108 | 108 |
|
| 109 | 109 |
# Collect the output of the job so far |
| 110 |
- sudo docker logs $JOB |
|
| 110 |
+ $ sudo docker logs $JOB |
|
| 111 | 111 |
|
| 112 | 112 |
# Kill the job |
| 113 |
- sudo docker kill $JOB |
|
| 113 |
+ $ sudo docker kill $JOB |
|
| 114 | 114 |
|
| 115 | 115 |
## Listing containers |
| 116 | 116 |
|
| 117 |
- sudo docker ps # Lists only running containers |
|
| 118 |
- sudo docker ps -a # Lists all containers |
|
| 117 |
+ $ sudo docker ps # Lists only running containers |
|
| 118 |
+ $ sudo docker ps -a # Lists all containers |
|
| 119 | 119 |
|
| 120 | 120 |
## Controlling containers |
| 121 | 121 |
|
| 122 | 122 |
# Start a new container |
| 123 |
- JOB=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1; done") |
|
| 123 |
+ $ JOB=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1; done") |
|
| 124 | 124 |
|
| 125 | 125 |
# Stop the container |
| 126 |
- docker stop $JOB |
|
| 126 |
+ $ docker stop $JOB |
|
| 127 | 127 |
|
| 128 | 128 |
# Start the container |
| 129 |
- docker start $JOB |
|
| 129 |
+ $ docker start $JOB |
|
| 130 | 130 |
|
| 131 | 131 |
# Restart the container |
| 132 |
- docker restart $JOB |
|
| 132 |
+ $ docker restart $JOB |
|
| 133 | 133 |
|
| 134 | 134 |
# SIGKILL a container |
| 135 |
- docker kill $JOB |
|
| 135 |
+ $ docker kill $JOB |
|
| 136 | 136 |
|
| 137 | 137 |
# Remove a container |
| 138 |
- docker stop $JOB # Container must be stopped to remove it |
|
| 139 |
- docker rm $JOB |
|
| 138 |
+ $ docker stop $JOB # Container must be stopped to remove it |
|
| 139 |
+ $ docker rm $JOB |
|
| 140 | 140 |
|
| 141 | 141 |
## Bind a service on a TCP port |
| 142 | 142 |
|
| 143 | 143 |
# Bind port 4444 of this container, and tell netcat to listen on it |
| 144 |
- JOB=$(sudo docker run -d -p 4444 ubuntu:12.10 /bin/nc -l 4444) |
|
| 144 |
+ $ JOB=$(sudo docker run -d -p 4444 ubuntu:12.10 /bin/nc -l 4444) |
|
| 145 | 145 |
|
| 146 | 146 |
# Which public port is NATed to my container? |
| 147 |
- PORT=$(sudo docker port $JOB 4444 | awk -F: '{ print $2 }')
|
|
| 147 |
+ $ PORT=$(sudo docker port $JOB 4444 | awk -F: '{ print $2 }')
|
|
| 148 | 148 |
|
| 149 | 149 |
# Connect to the public port |
| 150 |
- echo hello world | nc 127.0.0.1 $PORT |
|
| 150 |
+ $ echo hello world | nc 127.0.0.1 $PORT |
|
| 151 | 151 |
|
| 152 | 152 |
# Verify that the network connection worked |
| 153 |
- echo "Daemon received: $(sudo docker logs $JOB)" |
|
| 153 |
+ $ echo "Daemon received: $(sudo docker logs $JOB)" |
|
| 154 | 154 |
|
| 155 | 155 |
## Committing (saving) a container state |
| 156 | 156 |
|
| ... | ... |
@@ -163,10 +163,10 @@ will be stored (as a diff). See which images you already have using the |
| 163 | 163 |
`docker images` command. |
| 164 | 164 |
|
| 165 | 165 |
# Commit your container to a new named image |
| 166 |
- sudo docker commit <container_id> <some_name> |
|
| 166 |
+ $ sudo docker commit <container_id> <some_name> |
|
| 167 | 167 |
|
| 168 | 168 |
# List your containers |
| 169 |
- sudo docker images |
|
| 169 |
+ $ sudo docker images |
|
| 170 | 170 |
|
| 171 | 171 |
You now have a image state from which you can create new instances. |
| 172 | 172 |
|
| ... | ... |
@@ -43,7 +43,7 @@ The next step is to pull a Docker image. For this, we have a resource: |
| 43 | 43 |
|
| 44 | 44 |
This is equivalent to running: |
| 45 | 45 |
|
| 46 |
- docker pull samalba/docker-registry |
|
| 46 |
+ $ docker pull samalba/docker-registry |
|
| 47 | 47 |
|
| 48 | 48 |
There are attributes available to control how long the cookbook will |
| 49 | 49 |
allow for downloading (5 minute default). |
| ... | ... |
@@ -68,7 +68,7 @@ managed by Docker. |
| 68 | 68 |
|
| 69 | 69 |
This is equivalent to running the following command, but under upstart: |
| 70 | 70 |
|
| 71 |
- docker run --detach=true --publish='5000:5000' --env='SETTINGS_FLAVOR=local' --volume='/mnt/docker:/docker-storage' samalba/docker-registry |
|
| 71 |
+ $ docker run --detach=true --publish='5000:5000' --env='SETTINGS_FLAVOR=local' --volume='/mnt/docker:/docker-storage' samalba/docker-registry |
|
| 72 | 72 |
|
| 73 | 73 |
The resources will accept a single string or an array of values for any |
| 74 | 74 |
docker flags that allow multiple values. |
| ... | ... |
@@ -84,7 +84,7 @@ In this scenario: |
| 84 | 84 |
inet addr:192.168.227.1 Bcast:192.168.227.255 Mask:255.255.255.0 |
| 85 | 85 |
|
| 86 | 86 |
# Run a container |
| 87 |
- $ docker run -i -t base /bin/bash |
|
| 87 |
+ docker run -i -t base /bin/bash |
|
| 88 | 88 |
|
| 89 | 89 |
# Container IP in the 192.168.227/24 range |
| 90 | 90 |
root@261c272cd7d5:/# ifconfig eth0 |
| ... | ... |
@@ -11,7 +11,7 @@ port. When this service runs inside a container, one can connect to the |
| 11 | 11 |
port after finding the IP address of the container as follows: |
| 12 | 12 |
|
| 13 | 13 |
# Find IP address of container with ID <container_id> |
| 14 |
- docker inspect <container_id> | grep IPAddress | cut -d '"' -f 4 |
|
| 14 |
+ $ docker inspect <container_id> | grep IPAddress | cut -d '"' -f 4 |
|
| 15 | 15 |
|
| 16 | 16 |
However, this IP address is local to the host system and the container |
| 17 | 17 |
port is not reachable by the outside world. Furthermore, even if the |
| ... | ... |
@@ -40,7 +40,7 @@ To bind a port of the container to a specific interface of the host |
| 40 | 40 |
system, use the `-p` parameter of the `docker run` command: |
| 41 | 41 |
|
| 42 | 42 |
# General syntax |
| 43 |
- docker run -p [([<host_interface>:[host_port]])|(<host_port>):]<container_port>[/udp] <image> <cmd> |
|
| 43 |
+ $ docker run -p [([<host_interface>:[host_port]])|(<host_port>):]<container_port>[/udp] <image> <cmd> |
|
| 44 | 44 |
|
| 45 | 45 |
When no host interface is provided, the port is bound to all available |
| 46 | 46 |
interfaces of the host machine (aka INADDR_ANY, or 0.0.0.0). When no |
| ... | ... |
@@ -48,32 +48,32 @@ host port is provided, one is dynamically allocated. The possible |
| 48 | 48 |
combinations of options for TCP port are the following: |
| 49 | 49 |
|
| 50 | 50 |
# Bind TCP port 8080 of the container to TCP port 80 on 127.0.0.1 of the host machine. |
| 51 |
- docker run -p 127.0.0.1:80:8080 <image> <cmd> |
|
| 51 |
+ $ docker run -p 127.0.0.1:80:8080 <image> <cmd> |
|
| 52 | 52 |
|
| 53 | 53 |
# Bind TCP port 8080 of the container to a dynamically allocated TCP port on 127.0.0.1 of the host machine. |
| 54 |
- docker run -p 127.0.0.1::8080 <image> <cmd> |
|
| 54 |
+ $ docker run -p 127.0.0.1::8080 <image> <cmd> |
|
| 55 | 55 |
|
| 56 | 56 |
# Bind TCP port 8080 of the container to TCP port 80 on all available interfaces of the host machine. |
| 57 |
- docker run -p 80:8080 <image> <cmd> |
|
| 57 |
+ $ docker run -p 80:8080 <image> <cmd> |
|
| 58 | 58 |
|
| 59 | 59 |
# Bind TCP port 8080 of the container to a dynamically allocated TCP port on all available interfaces of the host machine. |
| 60 |
- docker run -p 8080 <image> <cmd> |
|
| 60 |
+ $ docker run -p 8080 <image> <cmd> |
|
| 61 | 61 |
|
| 62 | 62 |
UDP ports can also be bound by adding a trailing `/udp`. All the |
| 63 | 63 |
combinations described for TCP work. Here is only one example: |
| 64 | 64 |
|
| 65 | 65 |
# Bind UDP port 5353 of the container to UDP port 53 on 127.0.0.1 of the host machine. |
| 66 |
- docker run -p 127.0.0.1:53:5353/udp <image> <cmd> |
|
| 66 |
+ $ docker run -p 127.0.0.1:53:5353/udp <image> <cmd> |
|
| 67 | 67 |
|
| 68 | 68 |
The command `docker port` lists the interface and port on the host machine |
| 69 | 69 |
bound to a given container port. It is useful when using dynamically allocated |
| 70 | 70 |
ports: |
| 71 | 71 |
|
| 72 | 72 |
# Bind to a dynamically allocated port |
| 73 |
- docker run -p 127.0.0.1::8080 --name dyn-bound <image> <cmd> |
|
| 73 |
+ $ docker run -p 127.0.0.1::8080 --name dyn-bound <image> <cmd> |
|
| 74 | 74 |
|
| 75 | 75 |
# Lookup the actual port |
| 76 |
- docker port dyn-bound 8080 |
|
| 76 |
+ $ docker port dyn-bound 8080 |
|
| 77 | 77 |
127.0.0.1:49160 |
| 78 | 78 |
|
| 79 | 79 |
## Linking a container |
| ... | ... |
@@ -99,24 +99,24 @@ exposure is done either through the `--expose` parameter to the `docker run` |
| 99 | 99 |
command, or the `EXPOSE` build command in a Dockerfile: |
| 100 | 100 |
|
| 101 | 101 |
# Expose port 80 |
| 102 |
- docker run --expose 80 --name server <image> <cmd> |
|
| 102 |
+ $ docker run --expose 80 --name server <image> <cmd> |
|
| 103 | 103 |
|
| 104 | 104 |
The `client` then links to the `server`: |
| 105 | 105 |
|
| 106 | 106 |
# Link |
| 107 |
- docker run --name client --link server:linked-server <image> <cmd> |
|
| 107 |
+ $ docker run --name client --link server:linked-server <image> <cmd> |
|
| 108 | 108 |
|
| 109 | 109 |
`client` locally refers to `server` as `linked-server`. The following |
| 110 | 110 |
environment variables, among others, are available on `client`: |
| 111 | 111 |
|
| 112 | 112 |
# The default protocol, ip, and port of the service running in the container |
| 113 |
- LINKED-SERVER_PORT=tcp://172.17.0.8:80 |
|
| 113 |
+ $ LINKED-SERVER_PORT=tcp://172.17.0.8:80 |
|
| 114 | 114 |
|
| 115 | 115 |
# A specific protocol, ip, and port of various services |
| 116 |
- LINKED-SERVER_PORT_80_TCP=tcp://172.17.0.8:80 |
|
| 117 |
- LINKED-SERVER_PORT_80_TCP_PROTO=tcp |
|
| 118 |
- LINKED-SERVER_PORT_80_TCP_ADDR=172.17.0.8 |
|
| 119 |
- LINKED-SERVER_PORT_80_TCP_PORT=80 |
|
| 116 |
+ $ LINKED-SERVER_PORT_80_TCP=tcp://172.17.0.8:80 |
|
| 117 |
+ $ LINKED-SERVER_PORT_80_TCP_PROTO=tcp |
|
| 118 |
+ $ LINKED-SERVER_PORT_80_TCP_ADDR=172.17.0.8 |
|
| 119 |
+ $ LINKED-SERVER_PORT_80_TCP_PORT=80 |
|
| 120 | 120 |
|
| 121 | 121 |
This tells `client` that a service is running on port 80 of `server` and that |
| 122 | 122 |
`server` is accessible at the IP address 172.17.0.8 |
| ... | ... |
@@ -23,7 +23,7 @@ The module is available on the [Puppet |
| 23 | 23 |
Forge](https://forge.puppetlabs.com/garethr/docker/) and can be |
| 24 | 24 |
installed using the built-in module tool. |
| 25 | 25 |
|
| 26 |
- puppet module install garethr/docker |
|
| 26 |
+ $ puppet module install garethr/docker |
|
| 27 | 27 |
|
| 28 | 28 |
It can also be found on |
| 29 | 29 |
[GitHub](https://github.com/garethr/garethr-docker) if you would |
| ... | ... |
@@ -47,7 +47,7 @@ defined type which can be used like so: |
| 47 | 47 |
|
| 48 | 48 |
This is equivalent to running: |
| 49 | 49 |
|
| 50 |
- docker pull ubuntu |
|
| 50 |
+ $ docker pull ubuntu |
|
| 51 | 51 |
|
| 52 | 52 |
Note that it will only be downloaded if an image of that name does not |
| 53 | 53 |
already exist. This is downloading a large binary so on first run can |
| ... | ... |
@@ -71,7 +71,7 @@ managed by Docker. |
| 71 | 71 |
|
| 72 | 72 |
This is equivalent to running the following command, but under upstart: |
| 73 | 73 |
|
| 74 |
- docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done" |
|
| 74 |
+ $ docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done" |
|
| 75 | 75 |
|
| 76 | 76 |
Run also contains a number of optional parameters: |
| 77 | 77 |
|
| ... | ... |
@@ -50,8 +50,8 @@ not. |
| 50 | 50 |
Or, you can use the VOLUME instruction in a Dockerfile to add one or |
| 51 | 51 |
more new volumes to any container created from that image: |
| 52 | 52 |
|
| 53 |
- # BUILD-USING: docker build -t data . |
|
| 54 |
- # RUN-USING: docker run -name DATA data |
|
| 53 |
+ # BUILD-USING: $ docker build -t data . |
|
| 54 |
+ # RUN-USING: $ docker run -name DATA data |
|
| 55 | 55 |
FROM busybox |
| 56 | 56 |
VOLUME ["/var/volume1", "/var/volume2"] |
| 57 | 57 |
CMD ["/bin/true"] |
| ... | ... |
@@ -108,7 +108,7 @@ For example: |
| 108 | 108 |
# Usage: |
| 109 | 109 |
# sudo docker run [OPTIONS] -v /(dir. on host):/(dir. in container):(Read-Write or Read-Only) [ARG..] |
| 110 | 110 |
# Example: |
| 111 |
- sudo docker run -i -t -v /var/log:/logs_from_host:ro ubuntu bash |
|
| 111 |
+ $ sudo docker run -i -t -v /var/log:/logs_from_host:ro ubuntu bash |
|
| 112 | 112 |
|
| 113 | 113 |
The command above mounts the host directory `/var/log` into the container |
| 114 | 114 |
with *read only* permissions as `/logs_from_host`. |
| ... | ... |
@@ -109,7 +109,7 @@ share one of your own images, then you must register a unique user name |
| 109 | 109 |
first. You can create your username and login on |
| 110 | 110 |
[Docker.io](https://index.docker.io/account/signup/), or by running |
| 111 | 111 |
|
| 112 |
- sudo docker login |
|
| 112 |
+ $ sudo docker login |
|
| 113 | 113 |
|
| 114 | 114 |
This will prompt you for a username, which will become a public |
| 115 | 115 |
namespace for your public repositories. |
| ... | ... |
@@ -199,10 +199,10 @@ identify a host), like this: |
| 199 | 199 |
# Tag to create a repository with the full registry location. |
| 200 | 200 |
# The location (e.g. localhost.localdomain:5000) becomes |
| 201 | 201 |
# a permanent part of the repository name |
| 202 |
- sudo docker tag 0u812deadbeef localhost.localdomain:5000/repo_name |
|
| 202 |
+ $ sudo docker tag 0u812deadbeef localhost.localdomain:5000/repo_name |
|
| 203 | 203 |
|
| 204 | 204 |
# Push the new repository to its home location on localhost |
| 205 |
- sudo docker push localhost.localdomain:5000/repo_name |
|
| 205 |
+ $ sudo docker push localhost.localdomain:5000/repo_name |
|
| 206 | 206 |
|
| 207 | 207 |
Once a repository has your registry's host name as part of the tag, you |
| 208 | 208 |
can push and pull it like any other repository, but it will **not** be |