Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)
| ... | ... |
@@ -34,23 +34,23 @@ controlled entirely from the `docker run` parameters. |
| 34 | 34 |
|
| 35 | 35 |
Start actual Redis server on one Docker host |
| 36 | 36 |
|
| 37 |
- big-server $ docker run -d --name redis crosbymichael/redis |
|
| 37 |
+ big-server $ sudo docker run -d --name redis crosbymichael/redis |
|
| 38 | 38 |
|
| 39 | 39 |
Then add an ambassador linked to the Redis server, mapping a port to the |
| 40 | 40 |
outside world |
| 41 | 41 |
|
| 42 |
- big-server $ docker run -d --link redis:redis --name redis_ambassador -p 6379:6379 svendowideit/ambassador |
|
| 42 |
+ big-server $ sudo docker run -d --link redis:redis --name redis_ambassador -p 6379:6379 svendowideit/ambassador |
|
| 43 | 43 |
|
| 44 | 44 |
On the other host, you can set up another ambassador setting environment |
| 45 | 45 |
variables for each remote port we want to proxy to the `big-server` |
| 46 | 46 |
|
| 47 |
- client-server $ docker run -d --name redis_ambassador --expose 6379 -e REDIS_PORT_6379_TCP=tcp://192.168.1.52:6379 svendowideit/ambassador |
|
| 47 |
+ client-server $ sudo docker run -d --name redis_ambassador --expose 6379 -e REDIS_PORT_6379_TCP=tcp://192.168.1.52:6379 svendowideit/ambassador |
|
| 48 | 48 |
|
| 49 | 49 |
Then on the `client-server` host, you can use a Redis client container |
| 50 | 50 |
to talk to the remote Redis server, just by linking to the local Redis |
| 51 | 51 |
ambassador. |
| 52 | 52 |
|
| 53 |
- client-server $ docker run -i -t --rm --link redis_ambassador:redis relateiq/redis-cli |
|
| 53 |
+ client-server $ sudo docker run -i -t --rm --link redis_ambassador:redis relateiq/redis-cli |
|
| 54 | 54 |
redis 172.17.0.160:6379> ping |
| 55 | 55 |
PONG |
| 56 | 56 |
|
| ... | ... |
@@ -62,19 +62,19 @@ does automatically (with a tiny amount of `sed`) |
| 62 | 62 |
On the Docker host (192.168.1.52) that Redis will run on: |
| 63 | 63 |
|
| 64 | 64 |
# start actual redis server |
| 65 |
- $ docker run -d --name redis crosbymichael/redis |
|
| 65 |
+ $ sudo docker run -d --name redis crosbymichael/redis |
|
| 66 | 66 |
|
| 67 | 67 |
# get a redis-cli container for connection testing |
| 68 |
- $ docker pull relateiq/redis-cli |
|
| 68 |
+ $ sudo docker pull relateiq/redis-cli |
|
| 69 | 69 |
|
| 70 | 70 |
# test the redis server by talking to it directly |
| 71 |
- $ docker run -t -i --rm --link redis:redis relateiq/redis-cli |
|
| 71 |
+ $ sudo docker run -t -i --rm --link redis:redis relateiq/redis-cli |
|
| 72 | 72 |
redis 172.17.0.136:6379> ping |
| 73 | 73 |
PONG |
| 74 | 74 |
^D |
| 75 | 75 |
|
| 76 | 76 |
# add redis ambassador |
| 77 |
- $ docker run -t -i --link redis:redis --name redis_ambassador -p 6379:6379 busybox sh |
|
| 77 |
+ $ sudo docker run -t -i --link redis:redis --name redis_ambassador -p 6379:6379 busybox sh |
|
| 78 | 78 |
|
| 79 | 79 |
In the `redis_ambassador` container, you can see the linked Redis |
| 80 | 80 |
containers `env`: |
| ... | ... |
@@ -96,9 +96,9 @@ containers `env`: |
| 96 | 96 |
This environment is used by the ambassador `socat` script to expose Redis |
| 97 | 97 |
to the world (via the `-p 6379:6379` port mapping): |
| 98 | 98 |
|
| 99 |
- $ docker rm redis_ambassador |
|
| 99 |
+ $ sudo docker rm redis_ambassador |
|
| 100 | 100 |
$ sudo ./contrib/mkimage-unittest.sh |
| 101 |
- $ docker run -t -i --link redis:redis --name redis_ambassador -p 6379:6379 docker-ut sh |
|
| 101 |
+ $ sudo docker run -t -i --link redis:redis --name redis_ambassador -p 6379:6379 docker-ut sh |
|
| 102 | 102 |
|
| 103 | 103 |
$ socat TCP4-LISTEN:6379,fork,reuseaddr TCP4:172.17.0.136:6379 |
| 104 | 104 |
|
| ... | ... |
@@ -107,14 +107,14 @@ Now ping the Redis server via the ambassador: |
| 107 | 107 |
Now go to a different server: |
| 108 | 108 |
|
| 109 | 109 |
$ sudo ./contrib/mkimage-unittest.sh |
| 110 |
- $ docker run -t -i --expose 6379 --name redis_ambassador docker-ut sh |
|
| 110 |
+ $ sudo docker run -t -i --expose 6379 --name redis_ambassador docker-ut sh |
|
| 111 | 111 |
|
| 112 | 112 |
$ socat TCP4-LISTEN:6379,fork,reuseaddr TCP4:192.168.1.52:6379 |
| 113 | 113 |
|
| 114 | 114 |
And get the `redis-cli` image so we can talk over the ambassador bridge. |
| 115 | 115 |
|
| 116 |
- $ docker pull relateiq/redis-cli |
|
| 117 |
- $ docker run -i -t --rm --link redis_ambassador:redis relateiq/redis-cli |
|
| 116 |
+ $ sudo docker pull relateiq/redis-cli |
|
| 117 |
+ $ sudo docker run -i -t --rm --link redis_ambassador:redis relateiq/redis-cli |
|
| 118 | 118 |
redis 172.17.0.160:6379> ping |
| 119 | 119 |
PONG |
| 120 | 120 |
|
| ... | ... |
@@ -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 |
+ $ sudo docker info |
|
| 14 | 14 |
|
| 15 | 15 |
If you get `docker: command not found` or something like |
| 16 | 16 |
`/var/lib/docker/repositories: permission denied` you may have an |
| ... | ... |
@@ -126,20 +126,20 @@ TCP and a Unix socket |
| 126 | 126 |
$ JOB=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1; done") |
| 127 | 127 |
|
| 128 | 128 |
# Stop the container |
| 129 |
- $ docker stop $JOB |
|
| 129 |
+ $ sudo docker stop $JOB |
|
| 130 | 130 |
|
| 131 | 131 |
# Start the container |
| 132 |
- $ docker start $JOB |
|
| 132 |
+ $ sudo docker start $JOB |
|
| 133 | 133 |
|
| 134 | 134 |
# Restart the container |
| 135 |
- $ docker restart $JOB |
|
| 135 |
+ $ sudo docker restart $JOB |
|
| 136 | 136 |
|
| 137 | 137 |
# SIGKILL a container |
| 138 |
- $ docker kill $JOB |
|
| 138 |
+ $ sudo docker kill $JOB |
|
| 139 | 139 |
|
| 140 | 140 |
# Remove a container |
| 141 |
- $ docker stop $JOB # Container must be stopped to remove it |
|
| 142 |
- $ docker rm $JOB |
|
| 141 |
+ $ sudo docker stop $JOB # Container must be stopped to remove it |
|
| 142 |
+ $ sudo docker rm $JOB |
|
| 143 | 143 |
|
| 144 | 144 |
## Bind a service on a TCP port |
| 145 | 145 |
|
| ... | ... |
@@ -94,7 +94,7 @@ your image with the docker build command, e.g., |
| 94 | 94 |
Start the container with `apache2` and `sshd` running and managed, forwarding |
| 95 | 95 |
a port to our SSH instance: |
| 96 | 96 |
|
| 97 |
- $ docker run -p 127.0.0.1:222:22 -d managed_image "/usr/sbin/sshd" "/etc/init.d/apache2 start" |
|
| 97 |
+ $ sudo docker run -p 127.0.0.1:222:22 -d managed_image "/usr/sbin/sshd" "/etc/init.d/apache2 start" |
|
| 98 | 98 |
|
| 99 | 99 |
We now clearly see one of the benefits of the cfe-docker integration: it |
| 100 | 100 |
allows to start several processes as part of a normal `docker run` command. |
| ... | ... |
@@ -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 |
+ $ sudo 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 |
+ $ sudo 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. |
| ... | ... |
@@ -122,7 +122,7 @@ providing a certificate trusted by our CA: |
| 122 | 122 |
To be able to connect to Docker and validate its certificate, you now |
| 123 | 123 |
need to provide your client keys, certificates and trusted CA: |
| 124 | 124 |
|
| 125 |
- $ docker --tlsverify --tlscacert=ca.pem --tlscert=cert.pem --tlskey=key.pem \ |
|
| 125 |
+ $ sudo docker --tlsverify --tlscacert=ca.pem --tlscert=cert.pem --tlskey=key.pem \ |
|
| 126 | 126 |
-H=dns-name-of-docker-host:2376 version |
| 127 | 127 |
|
| 128 | 128 |
> **Note**: |
| ... | ... |
@@ -148,7 +148,7 @@ the files to the `.docker` directory in your home directory - and set the |
| 148 | 148 |
|
| 149 | 149 |
Then you can run Docker with the `--tlsverify` option. |
| 150 | 150 |
|
| 151 |
- $ docker --tlsverify ps |
|
| 151 |
+ $ sudo docker --tlsverify ps |
|
| 152 | 152 |
|
| 153 | 153 |
## Other modes |
| 154 | 154 |
|
| ... | ... |
@@ -175,4 +175,4 @@ if you want to store your keys in another location, you can specify that |
| 175 | 175 |
location using the environment variable `DOCKER_CERT_PATH`. |
| 176 | 176 |
|
| 177 | 177 |
$ export DOCKER_CERT_PATH=${HOME}/.docker/zone1/
|
| 178 |
- $ docker --tlsverify ps |
|
| 178 |
+ $ sudo docker --tlsverify ps |
| ... | ... |
@@ -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 |
+ $ sudo 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 |
+ $ sudo 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 |
|
| ... | ... |
@@ -11,7 +11,7 @@ page_keywords: Docker, docker, registry, accounts, plans, Dockerfile, Docker Hub |
| 11 | 11 |
You can `search` for all the publicly available repositories and images using |
| 12 | 12 |
Docker. |
| 13 | 13 |
|
| 14 |
- $ docker search ubuntu |
|
| 14 |
+ $ sudo docker search ubuntu |
|
| 15 | 15 |
|
| 16 | 16 |
This will show you a list of the currently available repositories on the |
| 17 | 17 |
Docker Hub which match the provided keyword. |
| ... | ... |
@@ -104,7 +104,7 @@ host-mapped port to test as well. You need to use `docker ps` |
| 104 | 104 |
to find out what local host port the container is mapped to |
| 105 | 105 |
first: |
| 106 | 106 |
|
| 107 |
- $ docker ps |
|
| 107 |
+ $ sudo docker ps |
|
| 108 | 108 |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
| 109 | 109 |
5e24362f27f6 eg_postgresql:latest /usr/lib/postgresql/ About an hour ago Up About an hour 0.0.0.0:49153->5432/tcp pg_test |
| 110 | 110 |
$ psql -h localhost -p 49153 -d docker -U docker --password |
| ... | ... |
@@ -135,7 +135,7 @@ prompt, you can create a table and populate it. |
| 135 | 135 |
You can use the defined volumes to inspect the PostgreSQL log files and |
| 136 | 136 |
to backup your configuration and data: |
| 137 | 137 |
|
| 138 |
- $ docker run --rm --volumes-from pg_test -t -i busybox sh |
|
| 138 |
+ $ sudo docker run --rm --volumes-from pg_test -t -i busybox sh |
|
| 139 | 139 |
|
| 140 | 140 |
/ # ls |
| 141 | 141 |
bin etc lib linuxrc mnt proc run sys usr |
| ... | ... |
@@ -198,7 +198,7 @@ then run. |
| 198 | 198 |
Either by using the `docker` binary or via the API, the Docker client tells the Docker |
| 199 | 199 |
daemon to run a container. |
| 200 | 200 |
|
| 201 |
- $ docker run -i -t ubuntu /bin/bash |
|
| 201 |
+ $ sudo docker run -i -t ubuntu /bin/bash |
|
| 202 | 202 |
|
| 203 | 203 |
Let's break down this command. The Docker client is launched using the `docker` |
| 204 | 204 |
binary with the `run` option telling it to launch a new container. The bare |
| ... | ... |
@@ -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 |
+ $ sudo docker pull https://<registry>/repositories/samalba/busybox |
|
| 115 | 115 |
|
| 116 | 116 |
In this case, Docker bypasses the Docker Hub. However the security is not |
| 117 | 117 |
guaranteed (in case Registry A is corrupted) because there won't be any |
| ... | ... |
@@ -57,7 +57,7 @@ instructions. |
| 57 | 57 |
Whenever possible, Docker will re-use the intermediate images, |
| 58 | 58 |
accelerating `docker build` significantly (indicated by `Using cache`): |
| 59 | 59 |
|
| 60 |
- $ docker build -t SvenDowideit/ambassador . |
|
| 60 |
+ $ sudo docker build -t SvenDowideit/ambassador . |
|
| 61 | 61 |
Uploading context 10.24 kB |
| 62 | 62 |
Uploading context |
| 63 | 63 |
Step 1 : FROM docker-ut |
| ... | ... |
@@ -109,7 +109,7 @@ The following example shows the use of the `.dockerignore` file to exclude the |
| 109 | 109 |
`.git` directory from the context. Its effect can be seen in the changed size of |
| 110 | 110 |
the uploaded context. |
| 111 | 111 |
|
| 112 |
- $ docker build . |
|
| 112 |
+ $ sudo docker build . |
|
| 113 | 113 |
Uploading context 18.829 MB |
| 114 | 114 |
Uploading context |
| 115 | 115 |
Step 0 : FROM busybox |
| ... | ... |
@@ -119,7 +119,7 @@ the uploaded context. |
| 119 | 119 |
---> 99cc1ad10469 |
| 120 | 120 |
Successfully built 99cc1ad10469 |
| 121 | 121 |
$ echo ".git" > .dockerignore |
| 122 |
- $ docker build . |
|
| 122 |
+ $ sudo docker build . |
|
| 123 | 123 |
Uploading context 6.76 MB |
| 124 | 124 |
Uploading context |
| 125 | 125 |
Step 0 : FROM busybox |
| ... | ... |
@@ -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 |
+ $ sudo 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 |
+ $ sudo docker run -v /host:/container example/mysql |
|
| 43 | 43 |
|
| 44 | 44 |
### Strings and Integers |
| 45 | 45 |
|
| ... | ... |
@@ -104,10 +104,10 @@ To use lxc as the execution driver, use `docker -d -e lxc`. |
| 104 | 104 |
The docker client will also honor the `DOCKER_HOST` environment variable to set |
| 105 | 105 |
the `-H` flag for the client. |
| 106 | 106 |
|
| 107 |
- $ docker -H tcp://0.0.0.0:2375 ps |
|
| 107 |
+ $ sudo docker -H tcp://0.0.0.0:2375 ps |
|
| 108 | 108 |
# or |
| 109 | 109 |
$ export DOCKER_HOST="tcp://0.0.0.0:2375" |
| 110 |
- $ docker ps |
|
| 110 |
+ $ sudo docker ps |
|
| 111 | 111 |
# both are equal |
| 112 | 112 |
|
| 113 | 113 |
To run the daemon with [systemd socket activation]( |
| ... | ... |
@@ -271,7 +271,7 @@ If you wish to keep the intermediate containers after the build is |
| 271 | 271 |
complete, you must use `--rm=false`. This does not |
| 272 | 272 |
affect the build cache. |
| 273 | 273 |
|
| 274 |
- $ docker build . |
|
| 274 |
+ $ sudo docker build . |
|
| 275 | 275 |
Uploading context 18.829 MB |
| 276 | 276 |
Uploading context |
| 277 | 277 |
Step 0 : FROM busybox |
| ... | ... |
@@ -281,7 +281,7 @@ affect the build cache. |
| 281 | 281 |
---> 99cc1ad10469 |
| 282 | 282 |
Successfully built 99cc1ad10469 |
| 283 | 283 |
$ echo ".git" > .dockerignore |
| 284 |
- $ docker build . |
|
| 284 |
+ $ sudo docker build . |
|
| 285 | 285 |
Uploading context 6.76 MB |
| 286 | 286 |
Uploading context |
| 287 | 287 |
Step 0 : FROM busybox |
| ... | ... |
@@ -355,9 +355,9 @@ If this behavior is undesired, set the 'p' option to false. |
| 355 | 355 |
ID IMAGE COMMAND CREATED STATUS PORTS |
| 356 | 356 |
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours |
| 357 | 357 |
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours |
| 358 |
- $ docker commit c3f279d17e0a SvenDowideit/testimage:version3 |
|
| 358 |
+ $ sudo docker commit c3f279d17e0a SvenDowideit/testimage:version3 |
|
| 359 | 359 |
f5283438590d |
| 360 |
- $ docker images | head |
|
| 360 |
+ $ sudo docker images | head |
|
| 361 | 361 |
REPOSITORY TAG ID CREATED VIRTUAL SIZE |
| 362 | 362 |
SvenDowideit/testimage version3 f5283438590d 16 seconds ago 335.7 MB |
| 363 | 363 |
|
| ... | ... |
@@ -464,7 +464,7 @@ For example: |
| 464 | 464 |
|
| 465 | 465 |
To see how the `docker:latest` image was built: |
| 466 | 466 |
|
| 467 |
- $ docker history docker |
|
| 467 |
+ $ sudo docker history docker |
|
| 468 | 468 |
IMAGE CREATED CREATED BY SIZE |
| 469 | 469 |
3e23a5875458790b7a806f95f7ec0d0b2a5c1659bfc899c89f939f6d5b8f7094 8 days ago /bin/sh -c #(nop) ENV LC_ALL=C.UTF-8 0 B |
| 470 | 470 |
8578938dd17054dce7993d21de79e96a037400e8d28e15e7290fea4f65128a36 8 days ago /bin/sh -c dpkg-reconfigure locales && locale-gen C.UTF-8 && /usr/sbin/update-locale LANG=C.UTF-8 1.245 MB |
| ... | ... |
@@ -729,7 +729,7 @@ If you want to login to a self-hosted registry you can |
| 729 | 729 |
specify this by adding the server name. |
| 730 | 730 |
|
| 731 | 731 |
example: |
| 732 |
- $ docker login localhost:8080 |
|
| 732 |
+ $ sudo docker login localhost:8080 |
|
| 733 | 733 |
|
| 734 | 734 |
## logout |
| 735 | 735 |
|
| ... | ... |
@@ -739,7 +739,7 @@ specify this by adding the server name. |
| 739 | 739 |
|
| 740 | 740 |
For example: |
| 741 | 741 |
|
| 742 |
- $ docker logout localhost:8080 |
|
| 742 |
+ $ sudo docker logout localhost:8080 |
|
| 743 | 743 |
|
| 744 | 744 |
## logs |
| 745 | 745 |
|
| ... | ... |
@@ -772,17 +772,17 @@ log entry. |
| 772 | 772 |
You can find out all the ports mapped by not specifying a `PRIVATE_PORT`, or |
| 773 | 773 |
just a specific mapping: |
| 774 | 774 |
|
| 775 |
- $ docker ps test |
|
| 775 |
+ $ sudo docker ps test |
|
| 776 | 776 |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
| 777 | 777 |
b650456536c7 busybox:latest top 54 minutes ago Up 54 minutes 0.0.0.0:1234->9876/tcp, 0.0.0.0:4321->7890/tcp test |
| 778 |
- $ docker port test |
|
| 778 |
+ $ sudo docker port test |
|
| 779 | 779 |
7890/tcp -> 0.0.0.0:4321 |
| 780 | 780 |
9876/tcp -> 0.0.0.0:1234 |
| 781 |
- $ docker port test 7890/tcp |
|
| 781 |
+ $ sudo docker port test 7890/tcp |
|
| 782 | 782 |
0.0.0.0:4321 |
| 783 |
- $ docker port test 7890/udp |
|
| 783 |
+ $ sudo docker port test 7890/udp |
|
| 784 | 784 |
2014/06/24 11:53:36 Error: No public port '7890/udp' published for test |
| 785 |
- $ docker port test 7890 |
|
| 785 |
+ $ sudo docker port test 7890 |
|
| 786 | 786 |
0.0.0.0:4321 |
| 787 | 787 |
|
| 788 | 788 |
## pause |
| ... | ... |
@@ -820,7 +820,7 @@ further details. |
| 820 | 820 |
|
| 821 | 821 |
Running `docker ps` showing 2 linked containers. |
| 822 | 822 |
|
| 823 |
- $ docker ps |
|
| 823 |
+ $ sudo docker ps |
|
| 824 | 824 |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
| 825 | 825 |
4c01db0b339c ubuntu:12.04 bash 17 seconds ago Up 16 seconds webapp |
| 826 | 826 |
d7886598dbe2 crosbymichael/redis:latest /redis-server --dir 33 minutes ago Up 33 minutes 6379/tcp redis,webapp/db |
| ... | ... |
@@ -869,15 +869,15 @@ a protocol specifier (https://, for example). |
| 869 | 869 |
To download a particular image, or set of images (i.e., a repository), |
| 870 | 870 |
use `docker pull`: |
| 871 | 871 |
|
| 872 |
- $ docker pull debian |
|
| 872 |
+ $ sudo docker pull debian |
|
| 873 | 873 |
# will pull only the debian:latest image and its intermediate layers |
| 874 |
- $ docker pull debian:testing |
|
| 874 |
+ $ sudo docker pull debian:testing |
|
| 875 | 875 |
# will pull only the image named debian:testing and any intermediate layers |
| 876 | 876 |
# it is based on. (Typically the empty `scratch` image, a MAINTAINER layer, |
| 877 | 877 |
# and the un-tarred base). |
| 878 |
- $ docker pull --all-tags centos |
|
| 878 |
+ $ sudo docker pull --all-tags centos |
|
| 879 | 879 |
# will pull all the images from the centos repository |
| 880 |
- $ docker pull registry.hub.docker.com/debian |
|
| 880 |
+ $ sudo docker pull registry.hub.docker.com/debian |
|
| 881 | 881 |
# manually specifies the path to the default Docker registry. This could |
| 882 | 882 |
# be replaced with the path to a local registry to pull from another source. |
| 883 | 883 |
|
| ... | ... |
@@ -18,7 +18,7 @@ other `docker` command. |
| 18 | 18 |
|
| 19 | 19 |
The basic `docker run` command takes this form: |
| 20 | 20 |
|
| 21 |
- $ docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...] |
|
| 21 |
+ $ sudo docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...] |
|
| 22 | 22 |
|
| 23 | 23 |
To learn how to interpret the types of `[OPTIONS]`, |
| 24 | 24 |
see [*Option types*](/reference/commandline/cli/#option-types). |
| ... | ... |
@@ -91,7 +91,7 @@ streams]( https://github.com/docker/docker/blob/ |
| 91 | 91 |
specify to which of the three standard streams (`STDIN`, `STDOUT`, |
| 92 | 92 |
`STDERR`) you'd like to connect instead, as in: |
| 93 | 93 |
|
| 94 |
- $ docker run -a stdin -a stdout -i -t ubuntu /bin/bash |
|
| 94 |
+ $ sudo docker run -a stdin -a stdout -i -t ubuntu /bin/bash |
|
| 95 | 95 |
|
| 96 | 96 |
For interactive processes (like a shell) you will typically want a tty |
| 97 | 97 |
as well as persistent standard input (`STDIN`), so you'll use `-i -t` |
| ... | ... |
@@ -192,9 +192,9 @@ Example running a Redis container with Redis binding to `localhost` then |
| 192 | 192 |
running the `redis-cli` command and connecting to the Redis server over the |
| 193 | 193 |
`localhost` interface. |
| 194 | 194 |
|
| 195 |
- $ docker run -d --name redis example/redis --bind 127.0.0.1 |
|
| 195 |
+ $ sudo docker run -d --name redis example/redis --bind 127.0.0.1 |
|
| 196 | 196 |
$ # use the redis container's network stack to access localhost |
| 197 |
- $ docker run --rm -ti --net container:redis example/redis-cli -h 127.0.0.1 |
|
| 197 |
+ $ sudo docker run --rm -ti --net container:redis example/redis-cli -h 127.0.0.1 |
|
| 198 | 198 |
|
| 199 | 199 |
## Clean Up (–-rm) |
| 200 | 200 |
|
| ... | ... |
@@ -253,14 +253,14 @@ If you want to limit access to a specific device or devices you can use |
| 253 | 253 |
the `--device` flag. It allows you to specify one or more devices that |
| 254 | 254 |
will be accessible within the container. |
| 255 | 255 |
|
| 256 |
- $ docker run --device=/dev/snd:/dev/snd ... |
|
| 256 |
+ $ sudo docker run --device=/dev/snd:/dev/snd ... |
|
| 257 | 257 |
|
| 258 | 258 |
In addition to `--privileged`, the operator can have fine grain control over the |
| 259 | 259 |
capabilities using `--cap-add` and `--cap-drop`. By default, Docker has a default |
| 260 | 260 |
list of capabilities that are kept. Both flags support the value `all`, so if the |
| 261 | 261 |
operator wants to have all capabilities but `MKNOD` they could use: |
| 262 | 262 |
|
| 263 |
- $ docker run --cap-add=ALL --cap-drop=MKNOD ... |
|
| 263 |
+ $ sudo docker run --cap-add=ALL --cap-drop=MKNOD ... |
|
| 264 | 264 |
|
| 265 | 265 |
For interacting with the network stack, instead of using `--privileged` they |
| 266 | 266 |
should use `--cap-add=NET_ADMIN` to modify the network interfaces. |
| ... | ... |
@@ -299,7 +299,7 @@ Dockerfile instruction and how the operator can override that setting. |
| 299 | 299 |
Recall the optional `COMMAND` in the Docker |
| 300 | 300 |
commandline: |
| 301 | 301 |
|
| 302 |
- $ docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...] |
|
| 302 |
+ $ sudo docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...] |
|
| 303 | 303 |
|
| 304 | 304 |
This command is optional because the person who created the `IMAGE` may |
| 305 | 305 |
have already provided a default `COMMAND` using the Dockerfile `CMD` |
| ... | ... |
@@ -326,12 +326,12 @@ runtime by using a string to specify the new `ENTRYPOINT`. Here is an |
| 326 | 326 |
example of how to run a shell in a container that has been set up to |
| 327 | 327 |
automatically run something else (like `/usr/bin/redis-server`): |
| 328 | 328 |
|
| 329 |
- $ docker run -i -t --entrypoint /bin/bash example/redis |
|
| 329 |
+ $ sudo docker run -i -t --entrypoint /bin/bash example/redis |
|
| 330 | 330 |
|
| 331 | 331 |
or two examples of how to pass more parameters to that ENTRYPOINT: |
| 332 | 332 |
|
| 333 |
- $ docker run -i -t --entrypoint /bin/bash example/redis -c ls -l |
|
| 334 |
- $ docker run -i -t --entrypoint /usr/bin/redis-cli example/redis --help |
|
| 333 |
+ $ sudo docker run -i -t --entrypoint /bin/bash example/redis -c ls -l |
|
| 334 |
+ $ sudo docker run -i -t --entrypoint /usr/bin/redis-cli example/redis --help |
|
| 335 | 335 |
|
| 336 | 336 |
## EXPOSE (Incoming Ports) |
| 337 | 337 |
|
| ... | ... |
@@ -378,7 +378,7 @@ The operator can **set any environment variable** in the container by |
| 378 | 378 |
using one or more `-e` flags, even overriding those already defined by |
| 379 | 379 |
the developer with a Dockerfile `ENV`: |
| 380 | 380 |
|
| 381 |
- $ docker run -e "deep=purple" --rm ubuntu /bin/bash -c export |
|
| 381 |
+ $ sudo docker run -e "deep=purple" --rm ubuntu /bin/bash -c export |
|
| 382 | 382 |
declare -x HOME="/" |
| 383 | 383 |
declare -x HOSTNAME="85bc26a0e200" |
| 384 | 384 |
declare -x OLDPWD |
| ... | ... |
@@ -396,23 +396,23 @@ information for connecting to the service container. Let's imagine we have a |
| 396 | 396 |
container running Redis: |
| 397 | 397 |
|
| 398 | 398 |
# Start the service container, named redis-name |
| 399 |
- $ docker run -d --name redis-name dockerfiles/redis |
|
| 399 |
+ $ sudo docker run -d --name redis-name dockerfiles/redis |
|
| 400 | 400 |
4241164edf6f5aca5b0e9e4c9eccd899b0b8080c64c0cd26efe02166c73208f3 |
| 401 | 401 |
|
| 402 | 402 |
# The redis-name container exposed port 6379 |
| 403 |
- $ docker ps |
|
| 403 |
+ $ sudo docker ps |
|
| 404 | 404 |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
| 405 | 405 |
4241164edf6f $ dockerfiles/redis:latest /redis-stable/src/re 5 seconds ago Up 4 seconds 6379/tcp redis-name |
| 406 | 406 |
|
| 407 | 407 |
# Note that there are no public ports exposed since we didn᾿t use -p or -P |
| 408 |
- $ docker port 4241164edf6f 6379 |
|
| 408 |
+ $ sudo docker port 4241164edf6f 6379 |
|
| 409 | 409 |
2014/01/25 00:55:38 Error: No public port '6379' published for 4241164edf6f |
| 410 | 410 |
|
| 411 | 411 |
Yet we can get information about the Redis container's exposed ports |
| 412 | 412 |
with `--link`. Choose an alias that will form a |
| 413 | 413 |
valid environment variable! |
| 414 | 414 |
|
| 415 |
- $ docker run --rm --link redis-name:redis_alias --entrypoint /bin/bash dockerfiles/redis -c export |
|
| 415 |
+ $ sudo docker run --rm --link redis-name:redis_alias --entrypoint /bin/bash dockerfiles/redis -c export |
|
| 416 | 416 |
declare -x HOME="/" |
| 417 | 417 |
declare -x HOSTNAME="acda7f7b1cdc" |
| 418 | 418 |
declare -x OLDPWD |
| ... | ... |
@@ -429,15 +429,15 @@ valid environment variable! |
| 429 | 429 |
|
| 430 | 430 |
And we can use that information to connect from another container as a client: |
| 431 | 431 |
|
| 432 |
- $ docker run -i -t --rm --link redis-name:redis_alias --entrypoint /bin/bash dockerfiles/redis -c '/redis-stable/src/redis-cli -h $REDIS_ALIAS_PORT_6379_TCP_ADDR -p $REDIS_ALIAS_PORT_6379_TCP_PORT' |
|
| 432 |
+ $ sudo docker run -i -t --rm --link redis-name:redis_alias --entrypoint /bin/bash dockerfiles/redis -c '/redis-stable/src/redis-cli -h $REDIS_ALIAS_PORT_6379_TCP_ADDR -p $REDIS_ALIAS_PORT_6379_TCP_PORT' |
|
| 433 | 433 |
172.17.0.32:6379> |
| 434 | 434 |
|
| 435 | 435 |
Docker will also map the private IP address to the alias of a linked |
| 436 | 436 |
container by inserting an entry into `/etc/hosts`. You can use this |
| 437 | 437 |
mechanism to communicate with a linked container by its alias: |
| 438 | 438 |
|
| 439 |
- $ docker run -d --name servicename busybox sleep 30 |
|
| 440 |
- $ docker run -i -t --link servicename:servicealias busybox ping -c 1 servicealias |
|
| 439 |
+ $ sudo docker run -d --name servicename busybox sleep 30 |
|
| 440 |
+ $ sudo docker run -i -t --link servicename:servicealias busybox ping -c 1 servicealias |
|
| 441 | 441 |
|
| 442 | 442 |
If you restart the source container (`servicename` in this case), the recipient |
| 443 | 443 |
container's `/etc/hosts` entry will be automatically updated. |
| ... | ... |
@@ -66,7 +66,7 @@ current port bindings. This is also useful for showing you specific port |
| 66 | 66 |
configurations. For example, if you've bound the container port to the |
| 67 | 67 |
`localhost` on the host machine, then the `docker port` output will reflect that. |
| 68 | 68 |
|
| 69 |
- $ docker port nostalgic_morse 5000 |
|
| 69 |
+ $ sudo docker port nostalgic_morse 5000 |
|
| 70 | 70 |
127.0.0.1:49155 |
| 71 | 71 |
|
| 72 | 72 |
> **Note:** |
| ... | ... |
@@ -137,7 +137,7 @@ image, which contains a PostgreSQL database. |
| 137 | 137 |
Now, you need to delete the `web` container you created previously so you can replace it |
| 138 | 138 |
with a linked one: |
| 139 | 139 |
|
| 140 |
- $ docker rm -f web |
|
| 140 |
+ $ sudo docker rm -f web |
|
| 141 | 141 |
|
| 142 | 142 |
Now, create a new `web` container and link it with your `db` container. |
| 143 | 143 |
|
| ... | ... |
@@ -153,7 +153,7 @@ alias for the link name. You'll see how that alias gets used shortly. |
| 153 | 153 |
|
| 154 | 154 |
Next, look at your linked containers using `docker ps`. |
| 155 | 155 |
|
| 156 |
- $ docker ps |
|
| 156 |
+ $ sudo docker ps |
|
| 157 | 157 |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
| 158 | 158 |
349169744e49 training/postgres:latest su postgres -c '/usr About a minute ago Up About a minute 5432/tcp db, web/db |
| 159 | 159 |
aed84ee21bde training/webapp:latest python app.py 16 hours ago Up 2 minutes 0.0.0.0:49154->5000/tcp web |
| ... | ... |
@@ -27,7 +27,7 @@ flags and arguments. |
| 27 | 27 |
|
| 28 | 28 |
# Usage: [sudo] docker [flags] [command] [arguments] .. |
| 29 | 29 |
# Example: |
| 30 |
- $ docker run -i -t ubuntu /bin/bash |
|
| 30 |
+ $ sudo docker run -i -t ubuntu /bin/bash |
|
| 31 | 31 |
|
| 32 | 32 |
Let's see this in action by using the `docker version` command to return |
| 33 | 33 |
version information on the currently installed Docker client and daemon. |