Skip to content

Commit

Permalink
Add blanks lines in docs for clarity
Browse files Browse the repository at this point in the history
Signed-off-by: Kara Alexandra <kalexandra@us.ibm.com>
  • Loading branch information
ardnaxelarak committed Jul 1, 2016
1 parent 9ba5e0f commit d0737e9
Show file tree
Hide file tree
Showing 25 changed files with 253 additions and 13 deletions.
16 changes: 16 additions & 0 deletions docs/tutorials/dockerimages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:**
Expand All @@ -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`
Expand All @@ -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
Expand All @@ -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`
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:**
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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)
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions docs/tutorials/dockerizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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

Expand All @@ -154,6 +161,7 @@ command.
Let's use the container name `insane_babbage`.

$ docker logs insane_babbage

hello world
hello world
hello world
Expand All @@ -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
Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions docs/tutorials/dockerrepos.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/tutorials/dockervolumes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 28 additions & 13 deletions docs/tutorials/networkingcontainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,40 @@ 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
`web`. If you want to re-use a container name you must delete the old 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


Expand All @@ -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
Expand All @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -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",
Expand Down Expand Up @@ -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"}}

Expand All @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit d0737e9

Please sign in to comment.