Merge pull request #24239 from ardnaxelarak/24130_clean_up_docs
[Docs code snippets] Make it obvious what is command what is result
This commit is contained in:
commit
c9e7390115
25 changed files with 253 additions and 13 deletions
|
@ -37,6 +37,7 @@ Let's start with listing the images you have locally on our host. You can
|
|||
do this using the `docker images` command like so:
|
||||
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
ubuntu 14.04 1d073211c498 3 days ago 187.9 MB
|
||||
busybox latest 2c5ac3f849df 5 days ago 1.113 MB
|
||||
|
@ -87,6 +88,7 @@ can download it using the `docker pull` command. Suppose you'd like to
|
|||
download the `centos` image.
|
||||
|
||||
$ docker pull centos
|
||||
|
||||
Pulling repository centos
|
||||
b7de3133ff98: Pulling dependent layers
|
||||
5cc9e91966f7: Pulling fs layer
|
||||
|
@ -101,6 +103,7 @@ can run a container from this image and you won't have to wait to
|
|||
download the image.
|
||||
|
||||
$ docker run -t -i centos /bin/bash
|
||||
|
||||
bash-4.1#
|
||||
|
||||
## Finding images
|
||||
|
@ -158,6 +161,7 @@ You've identified a suitable image, `training/sinatra`, and now you can download
|
|||
The team can now use this image by running their own containers.
|
||||
|
||||
$ docker run -t -i training/sinatra /bin/bash
|
||||
|
||||
root@a8cb6ce02d85:/#
|
||||
|
||||
## Creating our own images
|
||||
|
@ -176,6 +180,7 @@ To update an image you first need to create a container from the image
|
|||
you'd like to update.
|
||||
|
||||
$ docker run -t -i training/sinatra /bin/bash
|
||||
|
||||
root@0b2616b0e5a8:/#
|
||||
|
||||
> **Note:**
|
||||
|
@ -195,6 +200,7 @@ command.
|
|||
|
||||
$ docker commit -m "Added json gem" -a "Kate Smith" \
|
||||
0b2616b0e5a8 ouruser/sinatra:v2
|
||||
|
||||
4f177bd27a9ff0f6dc2a830403925b5360bfe0b93d476f7fc3231110e7f71b1c
|
||||
|
||||
Here you've used the `docker commit` command. You've specified two flags: `-m`
|
||||
|
@ -217,6 +223,7 @@ You can then look at our new `ouruser/sinatra` image using the `docker images`
|
|||
command.
|
||||
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
training/sinatra latest 5bc342fa0b91 10 hours ago 446.7 MB
|
||||
ouruser/sinatra v2 3c59e02ddd1a 10 hours ago 446.7 MB
|
||||
|
@ -225,6 +232,7 @@ command.
|
|||
To use our new image to create a container you can then:
|
||||
|
||||
$ docker run -t -i ouruser/sinatra:v2 /bin/bash
|
||||
|
||||
root@78e82f680994:/#
|
||||
|
||||
### Building an image from a `Dockerfile`
|
||||
|
@ -240,7 +248,9 @@ tell Docker how to build our image.
|
|||
First, create a directory and a `Dockerfile`.
|
||||
|
||||
$ mkdir sinatra
|
||||
|
||||
$ cd sinatra
|
||||
|
||||
$ touch Dockerfile
|
||||
|
||||
If you are using Docker Machine on Windows, you may access your host
|
||||
|
@ -275,6 +285,7 @@ Sinatra gem.
|
|||
Now let's take our `Dockerfile` and use the `docker build` command to build an image.
|
||||
|
||||
$ docker build -t ouruser/sinatra:v2 .
|
||||
|
||||
Sending build context to Docker daemon 2.048 kB
|
||||
Sending build context to Docker daemon
|
||||
Step 1 : FROM ubuntu:14.04
|
||||
|
@ -469,6 +480,7 @@ containers will get removed to clean things up.
|
|||
You can then create a container from our new image.
|
||||
|
||||
$ docker run -t -i ouruser/sinatra:v2 /bin/bash
|
||||
|
||||
root@8196968dac35:/#
|
||||
|
||||
> **Note:**
|
||||
|
@ -495,6 +507,7 @@ user name, the repository name and the new tag.
|
|||
Now, see your new tag using the `docker images` command.
|
||||
|
||||
$ docker images ouruser/sinatra
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
ouruser/sinatra latest 5db5f8471261 11 hours ago 446.7 MB
|
||||
ouruser/sinatra devel 5db5f8471261 11 hours ago 446.7 MB
|
||||
|
@ -508,6 +521,7 @@ unchanged, the digest value is predictable. To list image digest values, use
|
|||
the `--digests` flag:
|
||||
|
||||
$ docker images --digests | head
|
||||
|
||||
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
|
||||
ouruser/sinatra latest sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 5db5f8471261 11 hours ago 446.7 MB
|
||||
|
||||
|
@ -527,6 +541,7 @@ allows you to share it with others, either publicly, or push it into [a
|
|||
private repository](https://hub.docker.com/account/billing-plans/).
|
||||
|
||||
$ docker push ouruser/sinatra
|
||||
|
||||
The push refers to a repository [ouruser/sinatra] (len: 1)
|
||||
Sending image list
|
||||
Pushing repository ouruser/sinatra (3 tags)
|
||||
|
@ -540,6 +555,7 @@ containers](usingdocker.md) using the `docker rmi` command.
|
|||
Delete the `training/sinatra` image as you don't need it anymore.
|
||||
|
||||
$ docker rmi training/sinatra
|
||||
|
||||
Untagged: training/sinatra:latest
|
||||
Deleted: 5bc342fa0b91cabf65246837015197eecfa24b2213ed6a51a8974ae250fedd8d
|
||||
Deleted: ed0fffdcdae5eb2c3a55549857a8be7fc8bc4241fb19ad714364cbfd7a56b22f
|
||||
|
|
|
@ -30,6 +30,7 @@ Running an application inside a container takes a single command: `docker run`.
|
|||
Let's run a hello world container.
|
||||
|
||||
$ docker run ubuntu /bin/echo 'Hello world'
|
||||
|
||||
Hello world
|
||||
|
||||
You just launched your first container!
|
||||
|
@ -59,6 +60,7 @@ the container stops once the command is executed.
|
|||
Let's specify a new command to run in the container.
|
||||
|
||||
$ docker run -t -i ubuntu /bin/bash
|
||||
|
||||
root@af8bae53bdd3:/#
|
||||
|
||||
In this example:
|
||||
|
@ -78,8 +80,11 @@ command prompt inside it:
|
|||
Let's try running some commands inside the container:
|
||||
|
||||
root@af8bae53bdd3:/# pwd
|
||||
|
||||
/
|
||||
|
||||
root@af8bae53bdd3:/# ls
|
||||
|
||||
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
|
||||
|
||||
In this example:
|
||||
|
@ -100,6 +105,7 @@ finished, the container stops.
|
|||
Let's create a container that runs as a daemon.
|
||||
|
||||
$ docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
|
||||
|
||||
1e5535038e285177d5214659a068137486f96ee5c2e85a4ac52dc83f2ebe4147
|
||||
|
||||
In this example:
|
||||
|
@ -132,6 +138,7 @@ The `docker ps` command queries the Docker daemon for information about all the
|
|||
about.
|
||||
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
1e5535038e28 ubuntu /bin/sh -c 'while tr 2 minutes ago Up 1 minute insane_babbage
|
||||
|
||||
|
@ -154,6 +161,7 @@ command.
|
|||
Let's use the container name `insane_babbage`.
|
||||
|
||||
$ docker logs insane_babbage
|
||||
|
||||
hello world
|
||||
hello world
|
||||
hello world
|
||||
|
@ -169,6 +177,7 @@ Dockerized application!
|
|||
Next, run the `docker stop` command to stop our detached container.
|
||||
|
||||
$ docker stop insane_babbage
|
||||
|
||||
insane_babbage
|
||||
|
||||
The `docker stop` command tells Docker to politely stop the running
|
||||
|
@ -177,6 +186,7 @@ container and returns the name of the container it stopped.
|
|||
Let's check it worked with the `docker ps` command.
|
||||
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
|
||||
Excellent. Our container is stopped.
|
||||
|
|
|
@ -57,6 +57,7 @@ interface or by using the command line interface. Searching can find images by i
|
|||
name, user name, or description:
|
||||
|
||||
$ docker search centos
|
||||
|
||||
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
centos The official build of CentOS 1223 [OK]
|
||||
tianon/centos CentOS 5 and 6, created using rinse instea... 33
|
||||
|
@ -72,6 +73,7 @@ a user's repository from the image name.
|
|||
Once you've found the image you want, you can download it with `docker pull <imagename>`:
|
||||
|
||||
$ docker pull centos
|
||||
|
||||
Using default tag: latest
|
||||
latest: Pulling from library/centos
|
||||
f1b10cd84249: Pull complete
|
||||
|
|
|
@ -204,6 +204,7 @@ using the `docker volume create` command.
|
|||
|
||||
```bash
|
||||
$ docker volume create -d flocker --name my-named-volume -o size=20GB
|
||||
|
||||
$ docker run -d -P \
|
||||
-v my-named-volume:/opt/webapp \
|
||||
--name web training/webapp python app.py
|
||||
|
|
|
@ -41,26 +41,28 @@ You name your container by using the `--name` flag, for example launch a new con
|
|||
Use the `docker ps` command to check the name:
|
||||
|
||||
$ docker ps -l
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
aed84ee21bde training/webapp:latest python app.py 12 hours ago Up 2 seconds 0.0.0.0:49154->5000/tcp web
|
||||
|
||||
You can also use `docker inspect` with the container's name.
|
||||
|
||||
$ docker inspect web
|
||||
|
||||
[
|
||||
{
|
||||
"Id": "3ce51710b34f5d6da95e0a340d32aa2e6cf64857fb8cdb2a6c38f7c56f448143",
|
||||
"Created": "2015-10-25T22:44:17.854367116Z",
|
||||
"Path": "python",
|
||||
"Args": [
|
||||
"app.py"
|
||||
],
|
||||
"State": {
|
||||
"Status": "running",
|
||||
"Running": true,
|
||||
"Paused": false,
|
||||
"Restarting": false,
|
||||
"OOMKilled": false,
|
||||
{
|
||||
"Id": "3ce51710b34f5d6da95e0a340d32aa2e6cf64857fb8cdb2a6c38f7c56f448143",
|
||||
"Created": "2015-10-25T22:44:17.854367116Z",
|
||||
"Path": "python",
|
||||
"Args": [
|
||||
"app.py"
|
||||
],
|
||||
"State": {
|
||||
"Status": "running",
|
||||
"Running": true,
|
||||
"Paused": false,
|
||||
"Restarting": false,
|
||||
"OOMKilled": false,
|
||||
...
|
||||
|
||||
Container names must be unique. That means you can only call one container
|
||||
|
@ -68,8 +70,11 @@ Container names must be unique. That means you can only call one container
|
|||
(with `docker rm`) before you can reuse the name with a new container. Go ahead and stop and remove your old `web` container.
|
||||
|
||||
$ docker stop web
|
||||
|
||||
web
|
||||
|
||||
$ docker rm web
|
||||
|
||||
web
|
||||
|
||||
|
||||
|
@ -83,6 +88,7 @@ that you can create your own drivers but that is an advanced task.
|
|||
Every installation of the Docker Engine automatically includes three default networks. You can list them:
|
||||
|
||||
$ docker network ls
|
||||
|
||||
NETWORK ID NAME DRIVER
|
||||
18a2866682b8 none null
|
||||
c288470c46f6 host host
|
||||
|
@ -91,12 +97,14 @@ Every installation of the Docker Engine automatically includes three default net
|
|||
The network named `bridge` is a special network. Unless you tell it otherwise, Docker always launches your containers in this network. Try this now:
|
||||
|
||||
$ docker run -itd --name=networktest ubuntu
|
||||
|
||||
74695c9cea6d9810718fddadc01a727a5dd3ce6a69d09752239736c030599741
|
||||
|
||||
Inspecting the network is an easy way to find out the container's IP address.
|
||||
|
||||
```bash
|
||||
$ docker network inspect bridge
|
||||
|
||||
[
|
||||
{
|
||||
"Name": "bridge",
|
||||
|
@ -153,6 +161,7 @@ Docker Engine natively supports both bridge networks and overlay networks. A bri
|
|||
The `-d` flag tells Docker to use the `bridge` driver for the new network. You could have left this flag off as `bridge` is the default value for this flag. Go ahead and list the networks on your machine:
|
||||
|
||||
$ docker network ls
|
||||
|
||||
NETWORK ID NAME DRIVER
|
||||
7b369448dccb bridge bridge
|
||||
615d565d498c my-bridge-network bridge
|
||||
|
@ -162,6 +171,7 @@ The `-d` flag tells Docker to use the `bridge` driver for the new network. You c
|
|||
If you inspect the network, you'll find that it has nothing in it.
|
||||
|
||||
$ docker network inspect my-bridge-network
|
||||
|
||||
[
|
||||
{
|
||||
"Name": "my-bridge-network",
|
||||
|
@ -196,6 +206,7 @@ If you inspect your `my-bridge-network` you'll see it has a container attached.
|
|||
You can also inspect your container to see where it is connected:
|
||||
|
||||
$ docker inspect --format='{{json .NetworkSettings.Networks}}' db
|
||||
|
||||
{"my-bridge-network":{"NetworkID":"7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99",
|
||||
"EndpointID":"508b170d56b2ac9e4ef86694b0a76a22dd3df1983404f7321da5649645bf7043","Gateway":"172.18.0.1","IPAddress":"172.18.0.2","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:11:00:02"}}
|
||||
|
||||
|
@ -206,17 +217,20 @@ Now, go ahead and start your by now familiar web application. This time leave of
|
|||
Which network is your `web` application running under? Inspect the application and you'll find it is running in the default `bridge` network.
|
||||
|
||||
$ docker inspect --format='{{json .NetworkSettings.Networks}}' web
|
||||
|
||||
{"bridge":{"NetworkID":"7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812",
|
||||
"EndpointID":"508b170d56b2ac9e4ef86694b0a76a22dd3df1983404f7321da5649645bf7043","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:11:00:02"}}
|
||||
|
||||
Then, get the IP address of your `web`
|
||||
|
||||
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' web
|
||||
|
||||
172.17.0.2
|
||||
|
||||
Now, open a shell to your running `db` container:
|
||||
|
||||
$ docker exec -it db bash
|
||||
|
||||
root@a205f0dd33b2:/# ping 172.17.0.2
|
||||
ping 172.17.0.2
|
||||
PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data.
|
||||
|
@ -233,6 +247,7 @@ Docker networking allows you to attach a container to as many networks as you li
|
|||
Open a shell into the `db` application again and try the ping command. This time just use the container name `web` rather than the IP Address.
|
||||
|
||||
$ docker exec -it db bash
|
||||
|
||||
root@a205f0dd33b2:/# ping web
|
||||
PING web (172.18.0.3) 56(84) bytes of data.
|
||||
64 bytes from web (172.18.0.3): icmp_seq=1 ttl=64 time=0.095 ms
|
||||
|
|
|
@ -115,6 +115,7 @@ Lastly, you've specified a command for our container to run: `python app.py`. Th
|
|||
Now you can see your running container using the `docker ps` command.
|
||||
|
||||
$ docker ps -l
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
bc533791f3f5 training/webapp:latest python app.py 5 seconds ago Up 2 seconds 0.0.0.0:49155->5000/tcp nostalgic_morse
|
||||
|
||||
|
@ -186,6 +187,7 @@ specify the ID or name of our container and then the port for which we need the
|
|||
corresponding public-facing port.
|
||||
|
||||
$ docker port nostalgic_morse 5000
|
||||
|
||||
0.0.0.0:49155
|
||||
|
||||
In this case you've looked up what port is mapped externally to port 5000 inside
|
||||
|
@ -197,6 +199,7 @@ You can also find out a bit more about what's happening with our application and
|
|||
use another of the commands you've learned, `docker logs`.
|
||||
|
||||
$ docker logs -f nostalgic_morse
|
||||
|
||||
* Running on http://0.0.0.0:5000/
|
||||
10.0.2.2 - - [23/May/2014 20:16:31] "GET / HTTP/1.1" 200 -
|
||||
10.0.2.2 - - [23/May/2014 20:16:31] "GET /favicon.ico HTTP/1.1" 404 -
|
||||
|
@ -212,6 +215,7 @@ In addition to the container's logs we can also examine the processes
|
|||
running inside it using the `docker top` command.
|
||||
|
||||
$ docker top nostalgic_morse
|
||||
|
||||
PID USER COMMAND
|
||||
854 root python app.py
|
||||
|
||||
|
@ -245,6 +249,7 @@ We can also narrow down the information we want to return by requesting a
|
|||
specific element, for example to return the container's IP address we would:
|
||||
|
||||
$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nostalgic_morse
|
||||
|
||||
172.17.0.5
|
||||
|
||||
## Stopping our web application container
|
||||
|
@ -253,6 +258,7 @@ Okay you've seen web application working. Now you can stop it using the
|
|||
`docker stop` command and the name of our container: `nostalgic_morse`.
|
||||
|
||||
$ docker stop nostalgic_morse
|
||||
|
||||
nostalgic_morse
|
||||
|
||||
We can now use the `docker ps` command to check if the container has
|
||||
|
@ -268,6 +274,7 @@ can create a new container or restart the old one. Look at
|
|||
starting your previous container back up.
|
||||
|
||||
$ docker start nostalgic_morse
|
||||
|
||||
nostalgic_morse
|
||||
|
||||
Now quickly run `docker ps -l` again to see the running container is
|
||||
|
@ -284,6 +291,7 @@ Your colleague has let you know that they've now finished with the container
|
|||
and won't need it again. Now, you can remove it using the `docker rm` command.
|
||||
|
||||
$ docker rm nostalgic_morse
|
||||
|
||||
Error: Impossible to remove a running container, please stop it first or use -f
|
||||
2014/05/24 08:12:56 Error: failed to remove one or more containers
|
||||
|
||||
|
@ -292,8 +300,11 @@ you from accidentally removing a running container you might need. You can try
|
|||
this again by stopping the container first.
|
||||
|
||||
$ docker stop nostalgic_morse
|
||||
|
||||
nostalgic_morse
|
||||
|
||||
$ docker rm nostalgic_morse
|
||||
|
||||
nostalgic_morse
|
||||
|
||||
And now our container is stopped and deleted.
|
||||
|
|
|
@ -29,8 +29,11 @@ It can be as simple as this to create an Ubuntu base image:
|
|||
|
||||
$ sudo debootstrap raring raring > /dev/null
|
||||
$ sudo tar -C raring -c . | docker import - raring
|
||||
|
||||
a29c15f1bf7a
|
||||
|
||||
$ docker run raring cat /etc/lsb-release
|
||||
|
||||
DISTRIB_ID=Ubuntu
|
||||
DISTRIB_RELEASE=13.04
|
||||
DISTRIB_CODENAME=raring
|
||||
|
|
|
@ -192,6 +192,7 @@ on how to query labels set on a container.
|
|||
These labels appear as part of the `docker info` output for the daemon:
|
||||
|
||||
$ docker -D info
|
||||
|
||||
Containers: 12
|
||||
Running: 5
|
||||
Paused: 2
|
||||
|
|
|
@ -23,6 +23,7 @@ when it starts:
|
|||
|
||||
```
|
||||
$ sudo iptables -t nat -L -n
|
||||
|
||||
...
|
||||
Chain POSTROUTING (policy ACCEPT)
|
||||
target prot opt source destination
|
||||
|
@ -56,6 +57,7 @@ network stack by examining your NAT tables.
|
|||
# is finished setting up a -P forward:
|
||||
|
||||
$ iptables -t nat -L -n
|
||||
|
||||
...
|
||||
Chain DOCKER (2 references)
|
||||
target prot opt source destination
|
||||
|
|
|
@ -27,8 +27,11 @@ stopping the service and removing the interface:
|
|||
# Stopping Docker and removing docker0
|
||||
|
||||
$ sudo service docker stop
|
||||
|
||||
$ sudo ip link set dev docker0 down
|
||||
|
||||
$ sudo brctl delbr docker0
|
||||
|
||||
$ sudo iptables -t nat -F POSTROUTING
|
||||
```
|
||||
|
||||
|
@ -41,12 +44,15 @@ customize `docker0`, but it will be enough to illustrate the technique.
|
|||
# Create our own bridge
|
||||
|
||||
$ sudo brctl addbr bridge0
|
||||
|
||||
$ sudo ip addr add 192.168.5.1/24 dev bridge0
|
||||
|
||||
$ sudo ip link set dev bridge0 up
|
||||
|
||||
# Confirming that our bridge is up and running
|
||||
|
||||
$ ip addr show bridge0
|
||||
|
||||
4: bridge0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP group default
|
||||
link/ether 66:38:d0:0d:76:18 brd ff:ff:ff:ff:ff:ff
|
||||
inet 192.168.5.1/24 scope global bridge0
|
||||
|
@ -55,11 +61,13 @@ $ ip addr show bridge0
|
|||
# Tell Docker about it and restart (on Ubuntu)
|
||||
|
||||
$ echo 'DOCKER_OPTS="-b=bridge0"' >> /etc/default/docker
|
||||
|
||||
$ sudo service docker start
|
||||
|
||||
# Confirming new outgoing NAT masquerade is set up
|
||||
|
||||
$ sudo iptables -t nat -L -n
|
||||
|
||||
...
|
||||
Chain POSTROUTING (policy ACCEPT)
|
||||
target prot opt source destination
|
||||
|
|
|
@ -20,6 +20,7 @@ How can Docker supply each container with a hostname and DNS configuration, with
|
|||
|
||||
```
|
||||
$$ mount
|
||||
|
||||
...
|
||||
/dev/disk/by-uuid/1fec...ebdf on /etc/hostname type ext4 ...
|
||||
/dev/disk/by-uuid/1fec...ebdf on /etc/hosts type ext4 ...
|
||||
|
|
|
@ -31,9 +31,13 @@ set `--ip-forward=false` and your system's kernel has it enabled, the
|
|||
or to turn it on manually:
|
||||
```
|
||||
$ sysctl net.ipv4.conf.all.forwarding
|
||||
|
||||
net.ipv4.conf.all.forwarding = 0
|
||||
|
||||
$ sysctl net.ipv4.conf.all.forwarding=1
|
||||
|
||||
$ sysctl net.ipv4.conf.all.forwarding
|
||||
|
||||
net.ipv4.conf.all.forwarding = 1
|
||||
```
|
||||
|
||||
|
@ -98,6 +102,7 @@ You can run the `iptables` command on your Docker host to see whether the `FORWA
|
|||
# When --icc=false, you should see a DROP rule:
|
||||
|
||||
$ sudo iptables -L -n
|
||||
|
||||
...
|
||||
Chain FORWARD (policy ACCEPT)
|
||||
target prot opt source destination
|
||||
|
@ -110,6 +115,7 @@ DROP all -- 0.0.0.0/0 0.0.0.0/0
|
|||
# the subsequent DROP policy for all other packets:
|
||||
|
||||
$ sudo iptables -L -n
|
||||
|
||||
...
|
||||
Chain FORWARD (policy ACCEPT)
|
||||
target prot opt source destination
|
||||
|
|
|
@ -30,6 +30,7 @@ Once you have one or more containers up and running, you can confirm that Docker
|
|||
# Display bridge info
|
||||
|
||||
$ sudo brctl show
|
||||
|
||||
bridge name bridge id STP enabled interfaces
|
||||
docker0 8000.3a1d7362b4ee no veth65f9
|
||||
vethdda6
|
||||
|
@ -45,6 +46,7 @@ Finally, the `docker0` Ethernet bridge settings are used every time you create a
|
|||
$ docker run -i -t --rm base /bin/bash
|
||||
|
||||
$$ ip addr show eth0
|
||||
|
||||
24: eth0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
|
||||
link/ether 32:6f:e0:35:57:91 brd ff:ff:ff:ff:ff:ff
|
||||
inet 172.17.0.3/16 scope global eth0
|
||||
|
@ -53,6 +55,7 @@ $$ ip addr show eth0
|
|||
valid_lft forever preferred_lft forever
|
||||
|
||||
$$ ip route
|
||||
|
||||
default via 172.17.42.1 dev eth0
|
||||
172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.3
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ range* on your Docker host. Next, when `docker ps` was run, you saw that port
|
|||
5000 in the container was bound to port 49155 on the host.
|
||||
|
||||
$ docker ps nostalgic_morse
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
bc533791f3f5 training/webapp:latest python app.py 5 seconds ago Up 2 seconds 0.0.0.0:49155->5000/tcp nostalgic_morse
|
||||
|
||||
|
@ -88,6 +89,7 @@ configurations. For example, if you've bound the container port to the
|
|||
`localhost` on the host machine, then the `docker port` output will reflect that.
|
||||
|
||||
$ docker port nostalgic_morse 5000
|
||||
|
||||
127.0.0.1:49155
|
||||
|
||||
> **Note:**
|
||||
|
@ -132,6 +134,7 @@ name the container `web`. You can see the container's name using the
|
|||
`docker ps` command.
|
||||
|
||||
$ docker ps -l
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
aed84ee21bde training/webapp:latest python app.py 12 hours ago Up 2 seconds 0.0.0.0:49154->5000/tcp web
|
||||
|
||||
|
@ -187,6 +190,7 @@ example as:
|
|||
Next, inspect your linked containers with `docker inspect`:
|
||||
|
||||
$ docker inspect -f "{{ .HostConfig.Links }}" web
|
||||
|
||||
[/db:/web/db]
|
||||
|
||||
You can see that the `web` container is now linked to the `db` container
|
||||
|
@ -273,6 +277,7 @@ command to list the specified container's environment variables.
|
|||
|
||||
```
|
||||
$ docker run --rm --name web2 --link db:db training/webapp env
|
||||
|
||||
. . .
|
||||
DB_NAME=/web2/db
|
||||
DB_PORT=tcp://172.17.0.5:5432
|
||||
|
@ -310,7 +315,9 @@ source container to the `/etc/hosts` file. Here's an entry for the `web`
|
|||
container:
|
||||
|
||||
$ docker run -t -i --rm --link db:webdb training/webapp /bin/bash
|
||||
|
||||
root@aed84ee21bde:/opt/webapp# cat /etc/hosts
|
||||
|
||||
172.17.0.7 aed84ee21bde
|
||||
. . .
|
||||
172.17.0.5 webdb 6e5cdeb2d300 db
|
||||
|
@ -324,7 +331,9 @@ also be added in `/etc/hosts` for the linked container's IP address. You can pin
|
|||
that host now via any of these entries:
|
||||
|
||||
root@aed84ee21bde:/opt/webapp# apt-get install -yqq inetutils-ping
|
||||
|
||||
root@aed84ee21bde:/opt/webapp# ping webdb
|
||||
|
||||
PING webdb (172.17.0.5): 48 data bytes
|
||||
56 bytes from 172.17.0.5: icmp_seq=0 ttl=64 time=0.267 ms
|
||||
56 bytes from 172.17.0.5: icmp_seq=1 ttl=64 time=0.250 ms
|
||||
|
@ -348,9 +357,13 @@ will be automatically updated with the source container's new IP address,
|
|||
allowing linked communication to continue.
|
||||
|
||||
$ docker restart db
|
||||
|
||||
db
|
||||
|
||||
$ docker run -t -i --rm --link db:db training/webapp /bin/bash
|
||||
|
||||
root@aed84ee21bde:/opt/webapp# cat /etc/hosts
|
||||
|
||||
172.17.0.7 aed84ee21bde
|
||||
. . .
|
||||
172.17.0.9 db
|
||||
|
|
|
@ -48,7 +48,9 @@ starting dockerd with `--ip-forward=false`):
|
|||
|
||||
```
|
||||
$ ip -6 route add 2001:db8:1::/64 dev docker0
|
||||
|
||||
$ sysctl net.ipv6.conf.default.forwarding=1
|
||||
|
||||
$ sysctl net.ipv6.conf.all.forwarding=1
|
||||
```
|
||||
|
||||
|
@ -113,6 +115,7 @@ configure the IPv6 addresses `2001:db8::c000` to `2001:db8::c00f`:
|
|||
|
||||
```
|
||||
$ ip -6 addr show
|
||||
|
||||
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536
|
||||
inet6 ::1/128 scope host
|
||||
valid_lft forever preferred_lft forever
|
||||
|
@ -165,6 +168,7 @@ device to the container network:
|
|||
|
||||
```
|
||||
$ ip -6 route show
|
||||
|
||||
2001:db8::c008/125 dev docker0 metric 1
|
||||
2001:db8::/64 dev eth0 proto kernel metric 256
|
||||
```
|
||||
|
|
|
@ -29,6 +29,7 @@ these networks using the `docker network ls` command:
|
|||
|
||||
```
|
||||
$ docker network ls
|
||||
|
||||
NETWORK ID NAME DRIVER
|
||||
7fca4eb8c647 bridge bridge
|
||||
9f904ee27bf5 none null
|
||||
|
@ -47,6 +48,7 @@ the `ifconfig` command on the host.
|
|||
|
||||
```
|
||||
$ ifconfig
|
||||
|
||||
docker0 Link encap:Ethernet HWaddr 02:42:47:bc:3a:eb
|
||||
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
|
||||
inet6 addr: fe80::42:47ff:febc:3aeb/64 Scope:Link
|
||||
|
@ -100,6 +102,7 @@ command returns information about a network:
|
|||
|
||||
```
|
||||
$ docker network inspect bridge
|
||||
|
||||
[
|
||||
{
|
||||
"Name": "bridge",
|
||||
|
@ -132,9 +135,11 @@ The `docker run` command automatically adds new containers to this network.
|
|||
|
||||
```
|
||||
$ docker run -itd --name=container1 busybox
|
||||
|
||||
3386a527aa08b37ea9232cbcace2d2458d49f44bb05a6b775fba7ddd40d8f92c
|
||||
|
||||
$ docker run -itd --name=container2 busybox
|
||||
|
||||
94447ca479852d29aeddca75c28f7104df3c3196d7b6d83061879e339946805c
|
||||
```
|
||||
|
||||
|
@ -142,6 +147,7 @@ Inspecting the `bridge` network again after starting two containers shows both n
|
|||
|
||||
```
|
||||
$ docker network inspect bridge
|
||||
|
||||
{[
|
||||
{
|
||||
"Name": "bridge",
|
||||
|
@ -215,6 +221,7 @@ Then use `ping` for about 3 seconds to test the connectivity of the containers o
|
|||
|
||||
```
|
||||
root@0cb243cd1293:/# ping -w3 172.17.0.3
|
||||
|
||||
PING 172.17.0.3 (172.17.0.3): 56 data bytes
|
||||
64 bytes from 172.17.0.3: seq=0 ttl=64 time=0.096 ms
|
||||
64 bytes from 172.17.0.3: seq=1 ttl=64 time=0.080 ms
|
||||
|
@ -229,6 +236,7 @@ Finally, use the `cat` command to check the `container1` network configuration:
|
|||
|
||||
```
|
||||
root@0cb243cd1293:/# cat /etc/hosts
|
||||
|
||||
172.17.0.2 3386a527aa08
|
||||
127.0.0.1 localhost
|
||||
::1 localhost ip6-localhost ip6-loopback
|
||||
|
@ -243,6 +251,7 @@ To detach from a `container1` and leave it running use `CTRL-p CTRL-q`.Then, att
|
|||
$ docker attach container2
|
||||
|
||||
root@0cb243cd1293:/# ifconfig
|
||||
|
||||
eth0 Link encap:Ethernet HWaddr 02:42:AC:11:00:03
|
||||
inet addr:172.17.0.3 Bcast:0.0.0.0 Mask:255.255.0.0
|
||||
inet6 addr: fe80::42:acff:fe11:3/64 Scope:Link
|
||||
|
@ -262,6 +271,7 @@ lo Link encap:Local Loopback
|
|||
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
|
||||
|
||||
root@0cb243cd1293:/# ping -w3 172.17.0.2
|
||||
|
||||
PING 172.17.0.2 (172.17.0.2): 56 data bytes
|
||||
64 bytes from 172.17.0.2: seq=0 ttl=64 time=0.067 ms
|
||||
64 bytes from 172.17.0.2: seq=1 ttl=64 time=0.075 ms
|
||||
|
@ -311,6 +321,7 @@ $ docker network create --driver bridge isolated_nw
|
|||
1196a4c5af43a21ae38ef34515b6af19236a3fc48122cf585e3f3054d509679b
|
||||
|
||||
$ docker network inspect isolated_nw
|
||||
|
||||
[
|
||||
{
|
||||
"Name": "isolated_nw",
|
||||
|
@ -332,6 +343,7 @@ $ docker network inspect isolated_nw
|
|||
]
|
||||
|
||||
$ docker network ls
|
||||
|
||||
NETWORK ID NAME DRIVER
|
||||
9f904ee27bf5 none null
|
||||
cf03ee007fb4 host host
|
||||
|
@ -344,6 +356,7 @@ After you create the network, you can launch containers on it using the `docker
|
|||
|
||||
```
|
||||
$ docker run --net=isolated_nw -itd --name=container3 busybox
|
||||
|
||||
8c1a0a5be480921d669a073393ade66a3fc49933f08bcc5515b37b8144f6d47c
|
||||
|
||||
$ docker network inspect isolated_nw
|
||||
|
|
|
@ -73,6 +73,7 @@ key-value stores. This example uses Consul.
|
|||
5. Run the `docker ps` command to see the `consul` container.
|
||||
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
4d51392253b3 progrium/consul "/bin/start -server -" 25 minutes ago Up 25 minutes 53/tcp, 53/udp, 8300-8302/tcp, 0.0.0.0:8500->8500/tcp, 8400/tcp, 8301-8302/udp admiring_panini
|
||||
|
||||
|
@ -111,6 +112,7 @@ that machine options that are needed by the `overlay` network driver.
|
|||
3. List your machines to confirm they are all up and running.
|
||||
|
||||
$ docker-machine ls
|
||||
|
||||
NAME ACTIVE DRIVER STATE URL SWARM
|
||||
default - virtualbox Running tcp://192.168.99.100:2376
|
||||
mh-keystore * virtualbox Running tcp://192.168.99.103:2376
|
||||
|
@ -134,6 +136,7 @@ To create an overlay network
|
|||
2. Use the `docker info` command to view the Swarm.
|
||||
|
||||
$ docker info
|
||||
|
||||
Containers: 3
|
||||
Images: 2
|
||||
Role: primary
|
||||
|
@ -171,6 +174,7 @@ To create an overlay network
|
|||
4. Check that the network is running:
|
||||
|
||||
$ docker network ls
|
||||
|
||||
NETWORK ID NAME DRIVER
|
||||
412c2496d0eb mhs-demo1/host host
|
||||
dd51763e6dd2 mhs-demo0/bridge bridge
|
||||
|
@ -187,14 +191,19 @@ To create an overlay network
|
|||
5. Switch to each Swarm agent in turn and list the networks.
|
||||
|
||||
$ eval $(docker-machine env mhs-demo0)
|
||||
|
||||
$ docker network ls
|
||||
|
||||
NETWORK ID NAME DRIVER
|
||||
6b07d0be843f my-net overlay
|
||||
dd51763e6dd2 bridge bridge
|
||||
b4234109bd9b none null
|
||||
1aeead6dd890 host host
|
||||
|
||||
$ eval $(docker-machine env mhs-demo1)
|
||||
|
||||
$ docker network ls
|
||||
|
||||
NETWORK ID NAME DRIVER
|
||||
d0bb78cbe7bd bridge bridge
|
||||
1c0eb8f69ebb none null
|
||||
|
@ -219,6 +228,7 @@ Once your network is created, you can start a container on any of the hosts and
|
|||
4. Run a BusyBox instance on the `mhs-demo1` instance and get the contents of the Nginx server's home page.
|
||||
|
||||
$ docker run -it --rm --net=my-net --env="constraint:node==mhs-demo1" busybox wget -O- http://web
|
||||
|
||||
Unable to find image 'busybox:latest' locally
|
||||
latest: Pulling from library/busybox
|
||||
ab2b8a86ca6c: Pull complete
|
||||
|
@ -268,6 +278,7 @@ to have external connectivity outside of their cluster.
|
|||
2. View the `docker_gwbridge` network, by listing the networks.
|
||||
|
||||
$ docker network ls
|
||||
|
||||
NETWORK ID NAME DRIVER
|
||||
6b07d0be843f my-net overlay
|
||||
dd51763e6dd2 bridge bridge
|
||||
|
@ -278,7 +289,9 @@ to have external connectivity outside of their cluster.
|
|||
3. Repeat steps 1 and 2 on the Swarm master.
|
||||
|
||||
$ eval $(docker-machine env mhs-demo0)
|
||||
|
||||
$ docker network ls
|
||||
|
||||
NETWORK ID NAME DRIVER
|
||||
6b07d0be843f my-net overlay
|
||||
d0bb78cbe7bd bridge bridge
|
||||
|
@ -289,6 +302,7 @@ to have external connectivity outside of their cluster.
|
|||
2. Check the Nginx container's network interfaces.
|
||||
|
||||
$ docker exec web ip addr
|
||||
|
||||
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
|
||||
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
|
||||
inet 127.0.0.1/8 scope host lo
|
||||
|
|
|
@ -42,7 +42,9 @@ bridge network for you.
|
|||
|
||||
```bash
|
||||
$ docker network create simple-network
|
||||
|
||||
69568e6336d8c96bbf57869030919f7c69524f71183b44d80948bd3927c87f6a
|
||||
|
||||
$ docker network inspect simple-network
|
||||
[
|
||||
{
|
||||
|
@ -134,8 +136,11 @@ For example, now let's use `-o` or `--opt` options to specify an IP address bind
|
|||
|
||||
```bash
|
||||
$ docker network create -o "com.docker.network.bridge.host_binding_ipv4"="172.23.0.1" my-network
|
||||
|
||||
b1a086897963e6a2e7fc6868962e55e746bee8ad0c97b54a5831054b5f62672a
|
||||
|
||||
$ docker network inspect my-network
|
||||
|
||||
[
|
||||
{
|
||||
"Name": "my-network",
|
||||
|
@ -158,9 +163,13 @@ $ docker network inspect my-network
|
|||
}
|
||||
}
|
||||
]
|
||||
|
||||
$ docker run -d -P --name redis --net my-network redis
|
||||
|
||||
bafb0c808c53104b2c90346f284bda33a69beadcab4fc83ab8f2c5a4410cd129
|
||||
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
bafb0c808c53 redis "/entrypoint.sh redis" 4 seconds ago Up 3 seconds 172.23.0.1:32770->6379/tcp redis
|
||||
```
|
||||
|
@ -179,9 +188,11 @@ Create two containers for this example:
|
|||
|
||||
```bash
|
||||
$ docker run -itd --name=container1 busybox
|
||||
|
||||
18c062ef45ac0c026ee48a83afa39d25635ee5f02b58de4abc8f467bcaa28731
|
||||
|
||||
$ docker run -itd --name=container2 busybox
|
||||
|
||||
498eaaaf328e1018042c04b2de04036fc04719a6e39a097a4f4866043a2c2152
|
||||
```
|
||||
|
||||
|
@ -189,6 +200,7 @@ Then create an isolated, `bridge` network to test with.
|
|||
|
||||
```bash
|
||||
$ docker network create -d bridge --subnet 172.25.0.0/16 isolated_nw
|
||||
|
||||
06a62f1c73c4e3107c0f555b7a5f163309827bfbbf999840166065a8f35455a8
|
||||
```
|
||||
|
||||
|
@ -197,7 +209,9 @@ the connection:
|
|||
|
||||
```
|
||||
$ docker network connect isolated_nw container2
|
||||
|
||||
$ docker network inspect isolated_nw
|
||||
|
||||
[
|
||||
{
|
||||
"Name": "isolated_nw",
|
||||
|
@ -234,6 +248,7 @@ the network on launch using the `docker run` command's `--net` option:
|
|||
|
||||
```bash
|
||||
$ docker run --net=isolated_nw --ip=172.25.3.3 -itd --name=container3 busybox
|
||||
|
||||
467a7863c3f0277ef8e661b38427737f28099b61fa55622d6c30fb288d88c551
|
||||
```
|
||||
|
||||
|
@ -251,6 +266,7 @@ Now, inspect the network resources used by `container3`.
|
|||
|
||||
```bash
|
||||
$ docker inspect --format='{{json .NetworkSettings.Networks}}' container3
|
||||
|
||||
{"isolated_nw":{"IPAMConfig":{"IPv4Address":"172.25.3.3"},"NetworkID":"1196a4c5af43a21ae38ef34515b6af19236a3fc48122cf585e3f3054d509679b",
|
||||
"EndpointID":"dffc7ec2915af58cc827d995e6ebdc897342be0420123277103c40ae35579103","Gateway":"172.25.0.1","IPAddress":"172.25.3.3","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:19:03:03"}}
|
||||
```
|
||||
|
@ -258,6 +274,7 @@ Repeat this command for `container2`. If you have Python installed, you can pret
|
|||
|
||||
```bash
|
||||
$ docker inspect --format='{{json .NetworkSettings.Networks}}' container2 | python -m json.tool
|
||||
|
||||
{
|
||||
"bridge": {
|
||||
"NetworkID":"7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812",
|
||||
|
@ -391,6 +408,7 @@ same network and cannot communicate. Test, this now by attaching to
|
|||
|
||||
```bash
|
||||
$ docker attach container3
|
||||
|
||||
/ # ping 172.17.0.2
|
||||
PING 172.17.0.2 (172.17.0.2): 56 data bytes
|
||||
^C
|
||||
|
@ -433,6 +451,7 @@ for other containers in the same network.
|
|||
|
||||
```bash
|
||||
$ docker run --net=isolated_nw -itd --name=container4 --link container5:c5 busybox
|
||||
|
||||
01b5df970834b77a9eadbaff39051f237957bd35c4c56f11193e0594cfd5117c
|
||||
```
|
||||
|
||||
|
@ -453,6 +472,7 @@ c4.
|
|||
|
||||
```bash
|
||||
$ docker run --net=isolated_nw -itd --name=container5 --link container4:c4 busybox
|
||||
|
||||
72eccf2208336f31e9e33ba327734125af00d1e1d2657878e2ee8154fbb23c7a
|
||||
```
|
||||
|
||||
|
@ -462,6 +482,7 @@ container name and its alias c5 and `container5` will be able to reach
|
|||
|
||||
```bash
|
||||
$ docker attach container4
|
||||
|
||||
/ # ping -w 4 c5
|
||||
PING c5 (172.25.0.5): 56 data bytes
|
||||
64 bytes from 172.25.0.5: seq=0 ttl=64 time=0.070 ms
|
||||
|
@ -487,6 +508,7 @@ round-trip min/avg/max = 0.070/0.081/0.097 ms
|
|||
|
||||
```bash
|
||||
$ docker attach container5
|
||||
|
||||
/ # ping -w 4 c4
|
||||
PING c4 (172.25.0.4): 56 data bytes
|
||||
64 bytes from 172.25.0.4: seq=0 ttl=64 time=0.065 ms
|
||||
|
@ -608,11 +630,13 @@ with a network alias.
|
|||
|
||||
```bash
|
||||
$ docker run --net=isolated_nw -itd --name=container6 --net-alias app busybox
|
||||
|
||||
8ebe6767c1e0361f27433090060b33200aac054a68476c3be87ef4005eb1df17
|
||||
```
|
||||
|
||||
```bash
|
||||
$ docker attach container4
|
||||
|
||||
/ # ping -w 4 app
|
||||
PING app (172.25.0.6): 56 data bytes
|
||||
64 bytes from 172.25.0.6: seq=0 ttl=64 time=0.070 ms
|
||||
|
@ -679,6 +703,7 @@ network-scoped alias within the same network. For example, let's launch
|
|||
|
||||
```bash
|
||||
$ docker run --net=isolated_nw -itd --name=container7 --net-alias app busybox
|
||||
|
||||
3138c678c123b8799f4c7cc6a0cecc595acbdfa8bf81f621834103cd4f504554
|
||||
```
|
||||
|
||||
|
@ -692,6 +717,7 @@ verify that `container7` is resolving the `app` alias.
|
|||
|
||||
```bash
|
||||
$ docker attach container4
|
||||
|
||||
/ # ping -w 4 app
|
||||
PING app (172.25.0.6): 56 data bytes
|
||||
64 bytes from 172.25.0.6: seq=0 ttl=64 time=0.070 ms
|
||||
|
@ -706,6 +732,7 @@ round-trip min/avg/max = 0.070/0.081/0.097 ms
|
|||
$ docker stop container6
|
||||
|
||||
$ docker attach container4
|
||||
|
||||
/ # ping -w 4 app
|
||||
PING app (172.25.0.7): 56 data bytes
|
||||
64 bytes from 172.25.0.7: seq=0 ttl=64 time=0.095 ms
|
||||
|
@ -728,6 +755,7 @@ disconnect` command.
|
|||
$ docker network disconnect isolated_nw container2
|
||||
|
||||
$ docker inspect --format='{{json .NetworkSettings.Networks}}' container2 | python -m json.tool
|
||||
|
||||
{
|
||||
"bridge": {
|
||||
"NetworkID":"7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812",
|
||||
|
@ -744,6 +772,7 @@ $ docker inspect --format='{{json .NetworkSettings.Networks}}' container2 | pyt
|
|||
|
||||
|
||||
$ docker network inspect isolated_nw
|
||||
|
||||
[
|
||||
{
|
||||
"Name": "isolated_nw",
|
||||
|
@ -831,12 +860,15 @@ be connected to the network.
|
|||
|
||||
```bash
|
||||
$ docker run -d --name redis_db --net multihost redis
|
||||
|
||||
ERROR: Cannot start container bc0b19c089978f7845633027aa3435624ca3d12dd4f4f764b61eac4c0610f32e: container already connected to network multihost
|
||||
|
||||
$ docker rm -f redis_db
|
||||
|
||||
$ docker network disconnect -f multihost redis_db
|
||||
|
||||
$ docker run -d --name redis_db --net multihost redis
|
||||
|
||||
7d986da974aeea5e9f7aca7e510bdb216d58682faa83a9040c2f2adc0544795a
|
||||
```
|
||||
|
||||
|
@ -851,6 +883,7 @@ $ docker network disconnect isolated_nw container3
|
|||
|
||||
```bash
|
||||
docker network inspect isolated_nw
|
||||
|
||||
[
|
||||
{
|
||||
"Name": "isolated_nw",
|
||||
|
@ -878,6 +911,7 @@ List all your networks to verify the `isolated_nw` was removed:
|
|||
|
||||
```bash
|
||||
$ docker network ls
|
||||
|
||||
NETWORK ID NAME DRIVER
|
||||
72314fa53006 host host
|
||||
f7ab26d71dbd bridge bridge
|
||||
|
|
|
@ -97,6 +97,7 @@ You can only use the AUFS storage driver on Linux systems with AUFS installed.
|
|||
Use the following command to determine if your system supports AUFS.
|
||||
|
||||
$ grep aufs /proc/filesystems
|
||||
|
||||
nodev aufs
|
||||
|
||||
This output indicates the system supports AUFS. Once you've verified your
|
||||
|
@ -116,6 +117,7 @@ Once your daemon is running, verify the storage driver with the `docker info`
|
|||
command.
|
||||
|
||||
$ sudo docker info
|
||||
|
||||
Containers: 1
|
||||
Images: 4
|
||||
Storage Driver: aufs
|
||||
|
@ -153,6 +155,7 @@ stacked below it in the union mount. Remember, these directory names do no map
|
|||
to image layer IDs with Docker 1.10 and higher.
|
||||
|
||||
$ cat /var/lib/docker/aufs/layers/91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c
|
||||
|
||||
d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82
|
||||
c22013c8472965aa5b62559f2b540cd440716ef149756e7b958a1b2aba421e87
|
||||
d3a1f33e8a5a513092f01bb7eb1c2abf4d711e5105390a3fe1ae2248cfde1391
|
||||
|
|
|
@ -112,6 +112,7 @@ commands. The example below shows a truncated output of an `ls -l` command an
|
|||
image layer:
|
||||
|
||||
$ ls -l /var/lib/docker/btrfs/subvolumes/0a17decee4139b0de68478f149cc16346f5e711c5ae3bb969895f22dd6723751/
|
||||
|
||||
total 0
|
||||
drwxr-xr-x 1 root root 1372 Oct 9 08:39 bin
|
||||
drwxr-xr-x 1 root root 0 Apr 10 2014 boot
|
||||
|
@ -173,6 +174,7 @@ Assuming your system meets the prerequisites, do the following:
|
|||
1. Install the "btrfs-tools" package.
|
||||
|
||||
$ sudo apt-get install btrfs-tools
|
||||
|
||||
Reading package lists... Done
|
||||
Building dependency tree
|
||||
<output truncated>
|
||||
|
@ -184,6 +186,7 @@ multiple devices to the `mkfs.btrfs` command creates a pool across all of those
|
|||
devices. Here you create a pool with a single device at `/dev/xvdb`.
|
||||
|
||||
$ sudo mkfs.btrfs -f /dev/xvdb
|
||||
|
||||
WARNING! - Btrfs v3.12 IS EXPERIMENTAL
|
||||
WARNING! - see http://btrfs.wiki.kernel.org before using
|
||||
|
||||
|
@ -209,6 +212,7 @@ multiple devices to the `mkfs.btrfs` command creates a pool across all of those
|
|||
a. Obtain the Btrfs filesystem's UUID.
|
||||
|
||||
$ sudo blkid /dev/xvdb
|
||||
|
||||
/dev/xvdb: UUID="a0ed851e-158b-4120-8416-c9b072c8cf47" UUID_SUB="c3927a64-4454-4eef-95c2-a7d44ac0cf27" TYPE="btrfs"
|
||||
|
||||
b. Create an `/etc/fstab` entry to automatically mount `/var/lib/docker`
|
||||
|
@ -222,7 +226,9 @@ remember to substitute the UUID value with the value obtained from the previous
|
|||
5. Mount the new filesystem and verify the operation.
|
||||
|
||||
$ sudo mount -a
|
||||
|
||||
$ mount
|
||||
|
||||
/dev/xvda1 on / type ext4 (rw,discard)
|
||||
<output truncated>
|
||||
/dev/xvdb on /var/lib/docker type btrfs (rw)
|
||||
|
@ -236,6 +242,7 @@ should automatically load with the `btrfs` storage driver.
|
|||
1. Start the Docker daemon.
|
||||
|
||||
$ sudo service docker start
|
||||
|
||||
docker start/running, process 2315
|
||||
|
||||
The procedure for starting the Docker daemon may differ depending on the
|
||||
|
@ -249,6 +256,7 @@ daemon` at startup, or adding it to the `DOCKER_OPTS` line to the Docker config
|
|||
2. Verify the storage driver with the `docker info` command.
|
||||
|
||||
$ sudo docker info
|
||||
|
||||
Containers: 0
|
||||
Images: 0
|
||||
Storage Driver: btrfs
|
||||
|
|
|
@ -182,6 +182,7 @@ You can detect the mode by viewing the `docker info` command:
|
|||
|
||||
```bash
|
||||
$ sudo docker info
|
||||
|
||||
Containers: 0
|
||||
Images: 0
|
||||
Storage Driver: devicemapper
|
||||
|
@ -416,6 +417,7 @@ the specifics of the existing configuration use `docker info`:
|
|||
|
||||
```bash
|
||||
$ sudo docker info
|
||||
|
||||
Containers: 0
|
||||
Running: 0
|
||||
Paused: 0
|
||||
|
@ -453,6 +455,7 @@ The `Data Space` values show that the pool is 100GB total. This example extends
|
|||
|
||||
```bash
|
||||
$ sudo ls -lh /var/lib/docker/devicemapper/devicemapper/
|
||||
|
||||
total 1175492
|
||||
-rw------- 1 root root 100G Mar 30 05:22 data
|
||||
-rw------- 1 root root 2.0G Mar 31 11:17 metadata
|
||||
|
@ -468,6 +471,7 @@ The `Data Space` values show that the pool is 100GB total. This example extends
|
|||
|
||||
```bash
|
||||
$ sudo ls -lh /var/lib/docker/devicemapper/devicemapper/
|
||||
|
||||
total 1.2G
|
||||
-rw------- 1 root root 200G Apr 14 08:47 data
|
||||
-rw------- 1 root root 2.0G Apr 19 13:27 metadata
|
||||
|
@ -477,9 +481,13 @@ The `Data Space` values show that the pool is 100GB total. This example extends
|
|||
|
||||
```bash
|
||||
$ sudo blockdev --getsize64 /dev/loop0
|
||||
|
||||
107374182400
|
||||
|
||||
$ sudo losetup -c /dev/loop0
|
||||
|
||||
$ sudo blockdev --getsize64 /dev/loop0
|
||||
|
||||
214748364800
|
||||
```
|
||||
|
||||
|
@ -489,6 +497,7 @@ The `Data Space` values show that the pool is 100GB total. This example extends
|
|||
|
||||
```bash
|
||||
$ sudo dmsetup status | grep pool
|
||||
|
||||
docker-8:1-123141-pool: 0 209715200 thin-pool 91
|
||||
422/524288 18338/1638400 - rw discard_passdown queue_if_no_space -
|
||||
```
|
||||
|
@ -499,6 +508,7 @@ The `Data Space` values show that the pool is 100GB total. This example extends
|
|||
|
||||
```bash
|
||||
$ sudo dmsetup table docker-8:1-123141-pool
|
||||
|
||||
0 209715200 thin-pool 7:1 7:0 128 32768 1 skip_block_zeroing
|
||||
```
|
||||
|
||||
|
@ -540,6 +550,7 @@ disk partition.
|
|||
|
||||
```bash
|
||||
$ sudo vgextend vg-docker /dev/sdh1
|
||||
|
||||
Volume group "vg-docker" successfully extended
|
||||
```
|
||||
|
||||
|
@ -549,6 +560,7 @@ disk partition.
|
|||
|
||||
```bash
|
||||
$ sudo lvextend -l+100%FREE -n vg-docker/data
|
||||
|
||||
Extending logical volume data to 200 GiB
|
||||
Logical volume data successfully resized
|
||||
```
|
||||
|
@ -559,6 +571,7 @@ disk partition.
|
|||
|
||||
```bash
|
||||
$ sudo dmsetup status | grep pool
|
||||
|
||||
docker-253:17-1835016-pool: 0 96460800 thin-pool 51593 6270/1048576 701943/753600 - rw no_discard_passdown queue_if_no_space
|
||||
```
|
||||
|
||||
|
@ -568,6 +581,7 @@ disk partition.
|
|||
|
||||
```bash
|
||||
$ sudo dmsetup table docker-253:17-1835016-pool
|
||||
|
||||
0 96460800 thin-pool 252:0 252:1 128 32768 1 skip_block_zeroing
|
||||
```
|
||||
|
||||
|
@ -580,6 +594,7 @@ disk partition.
|
|||
|
||||
```bash
|
||||
$ sudo blockdev --getsize64 /dev/vg-docker/data
|
||||
|
||||
264132100096
|
||||
```
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@ single 8GB general purpose SSD EBS volume. The Docker data directory
|
|||
(`/var/lib/docker`) was consuming 2GB of space.
|
||||
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
jenkins latest 285c9f0f9d3d 17 hours ago 708.5 MB
|
||||
mysql latest d39c3fa09ced 8 days ago 360.3 MB
|
||||
|
@ -111,9 +112,11 @@ single 8GB general purpose SSD EBS volume. The Docker data directory
|
|||
ubuntu 15.04 c8be1ac8145a 7 weeks ago 131.3 MB
|
||||
|
||||
$ sudo du -hs /var/lib/docker
|
||||
|
||||
2.0G /var/lib/docker
|
||||
|
||||
$ time docker run --rm -v /var/lib/docker:/var/lib/docker docker/v1.10-migrator
|
||||
|
||||
Unable to find image 'docker/v1.10-migrator:latest' locally
|
||||
latest: Pulling from docker/v1.10-migrator
|
||||
ed1f33c5883d: Pull complete
|
||||
|
@ -203,6 +206,7 @@ images with `docker pull` and `docker push`. The command below pulls the
|
|||
`ubuntu:15.04` Docker image from Docker Hub.
|
||||
|
||||
$ docker pull ubuntu:15.04
|
||||
|
||||
15.04: Pulling from library/ubuntu
|
||||
1ba8ac955b97: Pull complete
|
||||
f157c4e5ede7: Pull complete
|
||||
|
@ -226,6 +230,7 @@ image being pulled from Docker Hub, followed by a directory listing on a host
|
|||
running version 1.9.1 of the Docker Engine.
|
||||
|
||||
$ docker pull ubuntu:15.04
|
||||
|
||||
15.04: Pulling from library/ubuntu
|
||||
47984b517ca9: Pull complete
|
||||
df6e891a3ea9: Pull complete
|
||||
|
@ -235,6 +240,7 @@ running version 1.9.1 of the Docker Engine.
|
|||
Status: Downloaded newer image for ubuntu:15.04
|
||||
|
||||
$ ls /var/lib/docker/aufs/layers
|
||||
|
||||
47984b517ca9ca0312aced5c9698753ffa964c2015f2a5f18e5efa9848cf30e2
|
||||
c8be1ac8145a6e59a55667f573883749ad66eaeef92b4df17e5ea1260e2d7356
|
||||
df6e891a3ea9cdce2a388a2cf1b1711629557454fd120abd5be6d32329a0e0ac
|
||||
|
@ -294,6 +300,7 @@ command.
|
|||
command:
|
||||
|
||||
$ docker build -t changed-ubuntu .
|
||||
|
||||
Sending build context to Docker daemon 2.048 kB
|
||||
Step 1 : FROM ubuntu:15.04
|
||||
---> 3f7bcee56709
|
||||
|
@ -411,14 +418,23 @@ Let's see what happens if we spin up 5 containers based on our `changed-ubuntu`
|
|||
5 times.
|
||||
|
||||
$ docker run -dit changed-ubuntu bash
|
||||
|
||||
75bab0d54f3cf193cfdc3a86483466363f442fba30859f7dcd1b816b6ede82d4
|
||||
|
||||
$ docker run -dit changed-ubuntu bash
|
||||
|
||||
9280e777d109e2eb4b13ab211553516124a3d4d4280a0edfc7abf75c59024d47
|
||||
|
||||
$ docker run -dit changed-ubuntu bash
|
||||
|
||||
a651680bd6c2ef64902e154eeb8a064b85c9abf08ac46f922ad8dfc11bb5cd8a
|
||||
|
||||
$ docker run -dit changed-ubuntu bash
|
||||
|
||||
8eb24b3b2d246f225b24f2fca39625aaad71689c392a7b552b78baf264647373
|
||||
|
||||
$ docker run -dit changed-ubuntu bash
|
||||
|
||||
0ad25d06bdf6fca0dedc38301b2aff7478b3e1ce3d1acd676573bba57cb1cfef
|
||||
|
||||
This launches 5 containers based on the `changed-ubuntu` image. As each
|
||||
|
@ -442,6 +458,7 @@ creating each container.
|
|||
3. List the contents of the local storage area.
|
||||
|
||||
$ sudo ls /var/lib/docker/containers
|
||||
|
||||
0ad25d06bdf6fca0dedc38301b2aff7478b3e1ce3d1acd676573bba57cb1cfef
|
||||
9280e777d109e2eb4b13ab211553516124a3d4d4280a0edfc7abf75c59024d47
|
||||
75bab0d54f3cf193cfdc3a86483466363f442fba30859f7dcd1b816b6ede82d4
|
||||
|
|
|
@ -78,6 +78,7 @@ The following `docker pull` command shows a Docker host with downloading a
|
|||
Docker image comprising five layers.
|
||||
|
||||
$ sudo docker pull ubuntu
|
||||
|
||||
Using default tag: latest
|
||||
latest: Pulling from library/ubuntu
|
||||
|
||||
|
@ -98,6 +99,7 @@ layer IDs do not match the directory names in `/var/lib/docker/overlay`. This
|
|||
is normal behavior in Docker 1.10 and later.
|
||||
|
||||
$ ls -l /var/lib/docker/overlay/
|
||||
|
||||
total 20
|
||||
drwx------ 3 root root 4096 Jun 20 16:11 38f3ed2eac129654acef11c32670b534670c3a06e483fce313d72e3e0a15baa8
|
||||
drwx------ 3 root root 4096 Jun 20 16:11 55f1e14c361b90570df46371b20ce6d480c434981cbda5fd68c6ff61aa0a5358
|
||||
|
@ -110,8 +112,11 @@ hard links to the data that is shared with lower layers. This allows for
|
|||
efficient use of disk space.
|
||||
|
||||
$ ls -i /var/lib/docker/overlay/38f3ed2eac129654acef11c32670b534670c3a06e483fce313d72e3e0a15baa8/root/bin/ls
|
||||
|
||||
19793696 /var/lib/docker/overlay/38f3ed2eac129654acef11c32670b534670c3a06e483fce313d72e3e0a15baa8/root/bin/ls
|
||||
|
||||
$ ls -i /var/lib/docker/overlay/55f1e14c361b90570df46371b20ce6d480c434981cbda5fd68c6ff61aa0a5358/root/bin/ls
|
||||
|
||||
19793696 /var/lib/docker/overlay/55f1e14c361b90570df46371b20ce6d480c434981cbda5fd68c6ff61aa0a5358/root/bin/ls
|
||||
|
||||
Containers also exist on-disk in the Docker host's filesystem under
|
||||
|
@ -120,6 +125,7 @@ container using the `ls -l` command, you find the following file and
|
|||
directories.
|
||||
|
||||
$ ls -l /var/lib/docker/overlay/<directory-of-running-container>
|
||||
|
||||
total 16
|
||||
-rw-r--r-- 1 root root 64 Jun 20 16:39 lower-id
|
||||
drwxr-xr-x 1 root root 4096 Jun 20 16:39 merged
|
||||
|
@ -131,6 +137,7 @@ file contains the ID of the top layer of the image the container is based on.
|
|||
This is used by OverlayFS as the "lowerdir".
|
||||
|
||||
$ cat /var/lib/docker/overlay/ec444863a55a9f1ca2df72223d459c5d940a721b2288ff86a3f27be28b53be6c/lower-id
|
||||
|
||||
55f1e14c361b90570df46371b20ce6d480c434981cbda5fd68c6ff61aa0a5358
|
||||
|
||||
The "upper" directory is the containers read-write layer. Any changes made to
|
||||
|
@ -148,6 +155,7 @@ You can verify all of these constructs from the output of the `mount` command.
|
|||
(Ellipses and line breaks are used in the output below to enhance readability.)
|
||||
|
||||
$ mount | grep overlay
|
||||
|
||||
overlay on /var/lib/docker/overlay/ec444863a55a.../merged
|
||||
type overlay (rw,relatime,lowerdir=/var/lib/docker/overlay/55f1e14c361b.../root,
|
||||
upperdir=/var/lib/docker/overlay/ec444863a55a.../upper,
|
||||
|
@ -170,6 +178,7 @@ After downloading a five-layer image using `docker pull ubuntu`, you can see
|
|||
six directories under `/var/lib/docker/overlay2`.
|
||||
|
||||
$ ls -l /var/lib/docker/overlay2
|
||||
|
||||
total 24
|
||||
drwx------ 5 root root 4096 Jun 20 07:36 223c2864175491657d238e2664251df13b63adb8d050924fd1bfcdb278b866f7
|
||||
drwx------ 3 root root 4096 Jun 20 07:36 3a36935c9df35472229c57f4a27105a136f5e4dbef0f87905b2e506e494e348b
|
||||
|
@ -183,6 +192,7 @@ shortened identifiers are used for avoid hitting the page size limitation on
|
|||
mount arguments.
|
||||
|
||||
$ ls -l /var/lib/docker/overlay2/l
|
||||
|
||||
total 20
|
||||
lrwxrwxrwx 1 root root 72 Jun 20 07:36 6Y5IM2XC7TSNIJZZFLJCS6I4I4 -> ../3a36935c9df35472229c57f4a27105a136f5e4dbef0f87905b2e506e494e348b/diff
|
||||
lrwxrwxrwx 1 root root 72 Jun 20 07:36 B3WWEFKBG3PLLV737KZFIASSW7 -> ../4e9fa83caff3e8f4cc83693fa407a4a9fac9573deaf481506c102d484dd1e6a1/diff
|
||||
|
@ -194,10 +204,15 @@ The lowerest layer contains the "link" file which contains the name of the short
|
|||
identifier, and the "diff" directory which contains the contents.
|
||||
|
||||
$ ls /var/lib/docker/overlay2/3a36935c9df35472229c57f4a27105a136f5e4dbef0f87905b2e506e494e348b/
|
||||
|
||||
diff link
|
||||
|
||||
$ cat /var/lib/docker/overlay2/3a36935c9df35472229c57f4a27105a136f5e4dbef0f87905b2e506e494e348b/link
|
||||
|
||||
6Y5IM2XC7TSNIJZZFLJCS6I4I4
|
||||
|
||||
$ ls /var/lib/docker/overlay2/3a36935c9df35472229c57f4a27105a136f5e4dbef0f87905b2e506e494e348b/diff
|
||||
|
||||
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
|
||||
|
||||
The second layer contains the "lower" file for denoting the layer composition,
|
||||
|
@ -205,22 +220,30 @@ and the "diff" directory for the layer contents. It also contains the "merged"
|
|||
the "work" directories.
|
||||
|
||||
$ ls /var/lib/docker/overlay2/223c2864175491657d238e2664251df13b63adb8d050924fd1bfcdb278b866f7
|
||||
|
||||
diff link lower merged work
|
||||
|
||||
$ cat /var/lib/docker/overlay2/223c2864175491657d238e2664251df13b63adb8d050924fd1bfcdb278b866f7/lower
|
||||
|
||||
l/6Y5IM2XC7TSNIJZZFLJCS6I4I4
|
||||
|
||||
$ ls /var/lib/docker/overlay2/223c2864175491657d238e2664251df13b63adb8d050924fd1bfcdb278b866f7/diff/
|
||||
|
||||
etc sbin usr var
|
||||
|
||||
A directory for running container have similar files and directories as well.
|
||||
Note that the lower list is separated by ':', and ordered from highest layer to lower.
|
||||
|
||||
$ ls -l /var/lib/docker/overlay/<directory-of-running-container>
|
||||
|
||||
$ cat /var/lib/docker/overlay/<directory-of-running-container>/lower
|
||||
|
||||
l/DJA75GUWHWG7EWICFYX54FIOVT:l/B3WWEFKBG3PLLV737KZFIASSW7:l/JEYMODZYFCZFYSDABYXD5MF6YO:l/UL2MW33MSE3Q5VYIKBRN4ZAGQP:l/NFYKDW6APBCCUCTOUSYDH4DXAT:l/6Y5IM2XC7TSNIJZZFLJCS6I4I4
|
||||
|
||||
The result of `mount` is as follows:
|
||||
|
||||
$ mount | grep overlay
|
||||
|
||||
overlay on /var/lib/docker/overlay2/9186877cdf386d0a3b016149cf30c208f326dca307529e646afce5b3f83f5304/merged
|
||||
type overlay (rw,relatime,
|
||||
lowerdir=l/DJA75GUWHWG7EWICFYX54FIOVT:l/B3WWEFKBG3PLLV737KZFIASSW7:l/JEYMODZYFCZFYSDABYXD5MF6YO:l/UL2MW33MSE3Q5VYIKBRN4ZAGQP:l/NFYKDW6APBCCUCTOUSYDH4DXAT:l/6Y5IM2XC7TSNIJZZFLJCS6I4I4,
|
||||
|
@ -298,14 +321,17 @@ OverlayFS. The procedure assumes that the Docker daemon is in a stopped state.
|
|||
2. Verify your kernel version and that the overlay kernel module is loaded.
|
||||
|
||||
$ uname -r
|
||||
|
||||
3.19.0-21-generic
|
||||
|
||||
$ lsmod | grep overlay
|
||||
|
||||
overlay
|
||||
|
||||
3. Start the Docker daemon with the `overlay`/`overlay2` storage driver.
|
||||
|
||||
$ dockerd --storage-driver=overlay &
|
||||
|
||||
[1] 29403
|
||||
root@ip-10-0-0-174:/home/ubuntu# INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
|
||||
INFO[0000] Option DefaultDriver: bridge
|
||||
|
@ -321,6 +347,7 @@ OverlayFS. The procedure assumes that the Docker daemon is in a stopped state.
|
|||
4. Verify that the daemon is using the `overlay`/`overlay2` storage driver
|
||||
|
||||
$ docker info
|
||||
|
||||
Containers: 0
|
||||
Images: 0
|
||||
Storage Driver: overlay
|
||||
|
|
|
@ -47,6 +47,7 @@ To find out which storage driver is set on the daemon, you use the
|
|||
`docker info` command:
|
||||
|
||||
$ docker info
|
||||
|
||||
Containers: 0
|
||||
Images: 0
|
||||
Storage Driver: overlay
|
||||
|
@ -96,6 +97,7 @@ The following command shows how to start the Docker daemon with the
|
|||
$ dockerd --storage-driver=devicemapper &
|
||||
|
||||
$ docker info
|
||||
|
||||
Containers: 0
|
||||
Images: 0
|
||||
Storage Driver: devicemapper
|
||||
|
|
|
@ -136,6 +136,7 @@ you should substitute your own values throughout the procedure.
|
|||
2. Install the `zfs` package.
|
||||
|
||||
$ sudo apt-get install -y zfs
|
||||
|
||||
Reading package lists... Done
|
||||
Building dependency tree
|
||||
<output truncated>
|
||||
|
@ -143,6 +144,7 @@ you should substitute your own values throughout the procedure.
|
|||
3. Verify that the `zfs` module is loaded correctly.
|
||||
|
||||
$ lsmod | grep zfs
|
||||
|
||||
zfs 2813952 3
|
||||
zunicode 331776 1 zfs
|
||||
zcommon 57344 1 zfs
|
||||
|
@ -159,6 +161,7 @@ you should substitute your own values throughout the procedure.
|
|||
This is required for the `add-apt-repository` command.
|
||||
|
||||
$ sudo apt-get install -y software-properties-common
|
||||
|
||||
Reading package lists... Done
|
||||
Building dependency tree
|
||||
<output truncated>
|
||||
|
@ -166,6 +169,7 @@ you should substitute your own values throughout the procedure.
|
|||
2. Add the `zfs-native` package archive.
|
||||
|
||||
$ sudo add-apt-repository ppa:zfs-native/stable
|
||||
|
||||
The native ZFS filesystem for Linux. Install the ubuntu-zfs package.
|
||||
<output truncated>
|
||||
gpg: key F6B0FC61: public key "Launchpad PPA for Native ZFS for Linux" imported
|
||||
|
@ -177,6 +181,7 @@ you should substitute your own values throughout the procedure.
|
|||
archives.
|
||||
|
||||
$ sudo apt-get update
|
||||
|
||||
Ign http://us-west-2.ec2.archive.ubuntu.com trusty InRelease
|
||||
Get:1 http://us-west-2.ec2.archive.ubuntu.com trusty-updates InRelease [64.4 kB]
|
||||
<output truncated>
|
||||
|
@ -186,6 +191,7 @@ archives.
|
|||
4. Install the `ubuntu-zfs` package.
|
||||
|
||||
$ sudo apt-get install -y ubuntu-zfs
|
||||
|
||||
Reading package lists... Done
|
||||
Building dependency tree
|
||||
<output truncated>
|
||||
|
@ -197,6 +203,7 @@ archives.
|
|||
6. Verify that it loaded correctly.
|
||||
|
||||
$ lsmod | grep zfs
|
||||
|
||||
zfs 2768247 0
|
||||
zunicode 331170 1 zfs
|
||||
zcommon 55411 1 zfs
|
||||
|
@ -218,6 +225,7 @@ Once ZFS is installed and loaded, you're ready to configure ZFS for Docker.
|
|||
2. Check that the `zpool` exists.
|
||||
|
||||
$ sudo zfs list
|
||||
|
||||
NAME USED AVAIL REFER MOUNTPOINT
|
||||
zpool-docker 55K 3.84G 19K /zpool-docker
|
||||
|
||||
|
@ -228,6 +236,7 @@ Once ZFS is installed and loaded, you're ready to configure ZFS for Docker.
|
|||
4. Check that the previous step worked.
|
||||
|
||||
$ sudo zfs list -t all
|
||||
|
||||
NAME USED AVAIL REFER MOUNTPOINT
|
||||
zpool-docker 93.5K 3.84G 19K /zpool-docker
|
||||
zpool-docker/docker 19K 3.84G 19K /var/lib/docker
|
||||
|
@ -238,6 +247,7 @@ Once ZFS is installed and loaded, you're ready to configure ZFS for Docker.
|
|||
5. Start the Docker daemon.
|
||||
|
||||
$ sudo service docker start
|
||||
|
||||
docker start/running, process 2315
|
||||
|
||||
The procedure for starting the Docker daemon may differ depending on the
|
||||
|
@ -249,6 +259,7 @@ Once ZFS is installed and loaded, you're ready to configure ZFS for Docker.
|
|||
6. Verify that the daemon is using the `zfs` storage driver.
|
||||
|
||||
$ sudo docker info
|
||||
|
||||
Containers: 0
|
||||
Images: 0
|
||||
Storage Driver: zfs
|
||||
|
|
Loading…
Reference in a new issue