set up docker and run httpd in 2 vagrant machines. 2


#Try docker command


You can search docker image

```:bash
sudo docker search centos
```

```shell-session
NAME                           DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
centos                         The official build of CentOS.                   3536      [OK]       
jdeathe/centos-ssh             CentOS-6 6.9 x86_64 / CentOS-7 7.3.1611 x8...   79                   [OK]
tutum/centos                   Simple CentOS docker image with SSH access      33                   
kinogmt/centos-ssh             CentOS with SSH                                 15                   [OK]                
```

```:bash
sudo docker pull centos
```

You can see image in detail

```:bash
sudo docker inspect centos:latest
```

```:bash
sudo docker inspect 36540f
```

```shell-session
[
    {
        "Id": "sha256:36540f359ca3b021d4b6a37815e9177b6c2bb3817598979ea55aee7ecc5c2c1f",
        "RepoTags": [
            "centos:latest"
        ],
        "RepoDigests": [
            "centos@sha256:c1010e2fe2b635822d99a096b1f4184becf5d1c98707cbccae00be663a9b9131"
        ],
        "Parent": "",
        "Comment": "",
```

try Hello world

```:bash
sudo docker run centos echo "hello world"
```

You can check current container typing this command.

```:bash
sudo docker ps
```

There is nothing shown.

```shell-session
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
```

You can see a past one by using option -a

```:bash
sudo docker ps -a
```

Exited (0) means that it finished well

```shell-session
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS                         PORTS               NAMES
76074bdf7b87        centos              "echo 'hello world'"   3 minutes ago       Exited (0) 3 minutes ago                           upbeat_sammet
```



You can write it like this

```:bash
sudo docker ps -a -n=1
```

You can delete container like this.
76074bdf7b87 is ID

```:bash
sudo docker rm 76074bdf7b87
```

You can run free command in background.

```:bash
sudo docker run -d centos free -s 3
```

```:bash
sudo docker ps
```

```shell-session
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
e7e5f3d83f76        centos              "free -s 3"         21 seconds ago      Up 20 seconds                           fervent_nobel
```

You can see logs like this.

```:bash
sudo docker logs e7e5f3d83f76
```

```shell-session
              total        used        free      shared  buff/cache   available
Mem:         629984      102056       82684        2884      445244      407420
Swap:       1023996        1920     1022076
```

You can run this command in foreground.

```:bash
sudo docker attach --sig-proxy=false e7e5f3d83f76
```

You can go back by "Ctrl + C"

You can kill process like this.


```:bash
sudo docker kill e7e5f3d83f76
```

Check it. no process

```:bash
sudo docker ps
```

```shell-session
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
```

Check past one.

```:bash
sudo docker ps -a
```

```shell-session
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
e7e5f3d83f76        centos              "free -s 3"         21 seconds ago      Up 20 seconds                           fervent_nobel
```

```:bash
sudo docker start e7e5f3d83f76
```

Check process

```:bash
sudo docker ps
```

```shell-session
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
e7e5f3d83f76        centos              "free -s 3"         10 minutes ago      Up 2 seconds                            fervent_nobel
```

You can check process.

```:bash
sudo docker top e7e5f3d83f76 ax | unexpand -t20
```

[前はこちら](http://qiita.com/joji/items/39f5488308fc166964d8 "前はこちら") 
[続きはこちら](http://qiita.com/joji/items/99b798e95f67fe6892e7 "続きはこちら")