-
Notifications
You must be signed in to change notification settings - Fork 4
Docker practical
This page describes ...
We need, in this tutorial:
- ...
Authors | Christine Tranchant-Dubreuil |
---|---|
Research Unit | UMR DIADE |
Institut |
docker
using a Docker client on ubuntu 16.03
25-28/04/2017
- Displaying Docker Info
docker info
- Checking Client and Daemon version
docker version
- Searching for images
docker search
- Displaying Local Images
docker images
- Pulling images
docker pull
- Running and Managing containers
docker run
- Listing containers
docker ps
- Filtering containers with
docker ps --filter
- A more pratical container : a web application inside a container
- An other pratical container to check container process
- Running containers executed by detached mode or not finished
docker exec
- Displays the entire log output from the time the container was created
docker logs
- Starting a container
docker start
- Stopping a container
docker stop
ordocker kill
- Deleting containers
docker rm
- Building image from a container
- Building image from a docker file
- Viewing Image layers and history
docker history
- Docker file
CMD
instruction - Docker file
COPY
instruction - Specify a working directory
WORKDIR
- Specify maintener MAINTENER
- Specify environnement
ENV
- Add instruction
ADD
- Creating a volume
docker volume create
- Listing volumes
docker volume ls
- Mounting volumes
docker run -v
- Inspecting the mapped volume
docker inspect volume-name
- Deleting volumes
docker volume rm <volume_name>
ordocker rm -v <container_id>
- Mounting host folders to a volume
docker run -v [host path]:[container path]
- Sharing data between containers
VOLUME
specified in dockerfile
- Checking container network
docker netkwork inspect
- Creating your own network
docker netkwork create
- Connecting containers to multiple networks
docker netkwork connect
- Displaying port with `docker port'
root@ird-6-0:~# docker swarm init
Error response from daemon: could not choose an IP address to advertise since this system has multiple addresses on interface eth0 (159.203.67.250 and 10.17.0.46) - specify one with --advertise-addr
root@ird-6-0:~# docker swarm init -h
Flag shorthand -h has been deprecated, please use --help
Usage: docker swarm init [OPTIONS]
Initialize a swarm
Options:
--advertise-addr string Advertised address (format: <ip|interface>[:port])
--autolock Enable manager autolocking (requiring an unlock key to start a stopped manager)
--availability string Availability of the node ("active"|"pause"|"drain") (default "active")
--cert-expiry duration Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s)
--dispatcher-heartbeat duration Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)
--external-ca external-ca Specifications of one or more certificate signing endpoints
--force-new-cluster Force create a new cluster from current state
--help Print usage
--listen-addr node-addr Listen address (format: <ip|interface>[:port]) (default 0.0.0.0:2377)
--max-snapshots uint Number of additional Raft snapshots to retain
--snapshot-interval uint Number of log entries between Raft snapshots (default 10000)
--task-history-limit int Task history retention limit (default 5)
root@ird-6-0:~# docker swarm init --advertise-addr 159.203.67.250
Swarm initialized: current node (4xu1niz6wea3cwzpdlhc0n1x3) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join \
--token SWMTKN-1-66z98vcwsxo48u2jm1d4fuxm59ygi0mszmvfkl704e49sq4cpp-dcxsx140imu7xcf7z2lyddf2i \
159.203.67.250:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
root@ird-6-0:~# docker info
Containers: 3
Running: 2
Paused: 0
Stopped: 1
Images: 82
Server Version: 17.04.0-ce
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 112
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: active
NodeID: 4xu1niz6wea3cwzpdlhc0n1x3
Is Manager: true
ClusterID: yz9e03gue5xfbwx3f1bv4edxs
Managers: 1
Nodes: 1
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 3
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Node Address: 159.203.67.250
Manager Addresses:
159.203.67.250:2377
Runtimes: runc
Default Runtime: runc
Init Binary:
containerd version: 422e31ce907fd9c3833a38d7b8fdd023e5a76e73
runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.4.0-72-generic
Operating System: Ubuntu 16.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.953GiB
Name: ird-6-0
ID: Z4F7:T7MO:NF6E:VOG3:KJ5L:QVRC:QNLG:IVAL:E3XK:B2OL:LLRX:2XII
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: 18092004
Registry: https://index.docker.io/v1/
Labels:
provider=digitalocean
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
root@ird-6-0:~#
WARNING: No swap limit support
root@ird-6-0:~# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
4xu1niz6wea3cwzpdlhc0n1x3 * ird-6-0 Ready Active Leader
#add node1
docker swarm join --token SWMTKN-1-66z98vcwsxo48u2jm1d4fuxm59ygi0mszmvfkl704e49sq4cpp-dcxsx140imu7xcf7z2lyddf2i 159.203.67.250:2377
This node joined a swarm as a worker.
root@ird-6-0:~# docker swarm join-token worker
To add a worker to this swarm, run the following command:
docker swarm join \
--token SWMTKN-1-66z98vcwsxo48u2jm1d4fuxm59ygi0mszmvfkl704e49sq4cpp-dcxsx140imu7xcf7z2lyddf2i \
159.203.67.250:2377
root@ird-6-0:~#
root@ird-6-1:~#
#node0
root@ird-6-0:~# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
3b489jzzdc9shihz37g1buz41 ird-6-1 Ready Active
4xu1niz6wea3cwzpdlhc0n1x3 * ird-6-0 Ready Active Leader
veyc81zqcl039t07yoau6xdzp ird-6-2 Ready Active
root@ird-6-0:~#
root@ird-6-0:~# docker info
Containers: 6
Running: 5
Paused: 0
Stopped: 1
Images: 47
Server Version: 17.04.0-ce
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 75
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary:
containerd version: 422e31ce907fd9c3833a38d7b8fdd023e5a76e73
Kernel Version: 4.4.0-72-generic
Operating System: Ubuntu 16.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.953GiB
Name: ird-6-0
ID: Z4F7:T7MO:NF6E:VOG3:KJ5L:QVRC:QNLG:IVAL:E3XK:B2OL:LLRX:2XII
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: 18092004
Registry: https://index.docker.io/v1/
Labels:
provider=digitalocean
Experimental: false
Insecure Registries:
127.0.0.0/8
root@ird-6-0:~ docker version
Client:
Version: 17.04.0-ce
API version: 1.28
Go version: go1.7.5
Git commit: 4845c56
Built: Mon Apr 3 18:07:42 2017
OS/Arch: linux/amd64
Server:
Version: 17.04.0-ce
API version: 1.28 (minimum version 1.12)
Go version: go1.7.5
Git commit: 4845c56
Built: Mon Apr 3 18:07:42 2017
OS/Arch: linux/amd64
Experimental: false
root@ird-6-0:~ docker search java
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
java Java is a concurrent, class-based, and obj... 1351 [OK]
anapsix/alpine-java Oracle Java 8 (and 7) with GLIBC 2.23 over... 203 [OK]
isuper/java-oracle This repository contains all java releases... 53 [OK]
lwieske/java-8 Oracle Java 8 Container - Full + Slim - Ba... 33 [OK]
nimmis/java-centos This is docker images of CentOS 7 with dif... 25 [OK]
ibmjava Official IBM® SDK, Java™ Technology Editio... 24 [OK]
...
esycat/java Oracle Java 8 on Ubuntu LTS 0 [OK]
axeclbr/java Java on Alpinelinux in Docker. 0 [OK]
root@ird-6-0:~ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
To download an image from Docker Hub https://hub.docker.com/
root@ird-6-0:~ docker pull ubuntu
root@ird-6-0:~ docker pull ubuntu:12.04
root@ird-6-0:~ docker pull busybox
Using default tag: latest
latest: Pulling from library/busybox
7520415ce762: Pull complete
Digest: sha256:32f093055929dbc23dec4d03e09dfe971f5973a9ca5cf059cbfb644c206aa83f
Status: Downloaded newer image for busybox:latest
root@ird-6-0:~ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest 00f017a8c2a6 6 weeks ago 1.11MB
docker run [options] [image] [command] [args]
Before running, pulling image if not installed locally
root@ird-6-0:~ docker run ubuntu:14.04 echo "Hello world"
Unable to find image 'ubuntu:14.04' locally
14.04: Pulling from library/ubuntu
8f229c550c2e: Pull complete
8e1fb71e8df6: Pull complete
f75a34586856: Pull complete
8744e322b832: Pull complete
d5165bfce78f: Pull complete
Digest: sha256:edf05697d8ea17028a69726b4b450ad48da8b29884cd640fec950c904bfb50ce
Status: Downloaded newer image for ubuntu:14.04
Hello world
root@ird-6-0:~
Run a container installed locally
root@ird-6-0:~ docker run ubuntu:14.04 ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 10:44 ? 00:00:00 ps -ef
Notice the much faster execution time compared to the first container that was run. This is due to the fact that Docker now has the Ubuntu 14.04 image locally and thus does not need to download the image
Run a container with terminal docker run -i -t
-
-i
to connect to STDIN on the container -
-t
to get a pseudo-terminal - Note: You need to run a terminal process as your command (e.g. bash)
root@ird-6-0:~ docker run -i -t ubuntu:latest bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
aafe6b5e13de: Pull complete
0a2b43a72660: Pull complete
18bdd1e546d2: Pull complete
8198342c3e05: Pull complete
f56970a44fd4: Pull complete
Digest: sha256:f3a61450ae43896c4332bda5e78b453f4a93179045f20c8181043b26b5e79028
Status: Downloaded newer image for ubuntu:latest
root@b60639a139f1:/ touch test
root@b60639a139f1:/ ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys test tmp usr var
Exit the terminal
- to return to the host terminal with a shutdown of the container
exit
root@b60639a139f1:/ exit
exit
root@ird-6-0:~ docker run -i -t ubuntu:latest bash
root@46341dc98559:/ ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@46341dc98559:/ exit
- to exit the terminal without a shutdown hit
CTRL + P + Q
root@ird-6-0:~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d9fb65e39bbd ubuntu:14.04 "echo 'Hello world'" 3 minutes ago Exited (0) 3 minutes ago tender_shaw
3ab87f074a5e ubuntu:latest "bash" About an hour ago Up About an hour relaxed_banach
46341dc98559 ubuntu:latest "bash" About an hour ago Exited (0) About an hour ago amazing_franklin
Running a container in detached mode
root@ird-6-0:~# docker run -d centos:7 ping 127.0.0.1 -c 50
6d17a98cace19d01c9721f3d2ea45d09038c81d6c79aab3f99c0466cd092323c
root@ird-6-0:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6d17a98cace1 centos:7 "ping 127.0.0.1 -c 50" 17 seconds ago Up 17 seconds wizardly_noether
73e9f15a3481 centos:7 "ping 127.0.0.1 -c 50" 37 seconds ago Up 37 seconds vibrant_lichterman
3ab87f074a5e ubuntu:latest "bash" About an hour ago Up About an hour relaxed_banach
root@ird-6-0:~# docker ps
root@ird-6-0:~ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@ird-6-0:~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c7f596997107 ubuntu:14.04 "echo 'Hello world'" About a minute ago Exited (0) About a minute ago gracious_wozniak
8500fd529452 ubuntu:14.04 "ps -ef" About a minute ago Exited (0) About a minute ago wonderful_archimedes
2285688a10fd ubuntu:14.04 "echo 'Hello world'" 2 minutes ago Exited (0) 2 minutes ago unruffled_bose
root@ird-6-0:~#
root@ird-6-0:~ docker ps -a --no-trunc
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d9fb65e39bbd6c26292cb282ca2f4366aba66d5f48b44e730bc31226553ece11 ubuntu:14.04 "echo 'Hello world'" 4 minutes ago Exited (0) 4 minutes ago tender_shaw
3ab87f074a5e997a7ae521238c66cd377787f5e145a3e35aa9d5caa40fd3e45b ubuntu:latest "bash" About an hour ago Up About an hour relaxed_banach
46341dc98559b55dc7fe6d2ce1801e6ab9ddb9a9367a6834e36361fee3ad753a ubuntu:latest "bash" About an hour ago Exited (0) About an hour ago amazing_franklin
b60639a139f1141b3dbe5945c0987e17049156f04413d8127abbc39a28b37c11 ubuntu:latest "bash" About an hour ago Exited (0) About an hour ago frosty_darwin
c7f5969971073330a2fa4bbe53a44162ba0e53dbc264a359ac26188df7a2351a ubuntu:14.04 "echo 'Hello world'" About an hour ago Exited (0) About an hour ago gracious_wozniak
8500fd52945293643ee51074a782557abcdaaeeaca776c4258d203e8203e3963 ubuntu:14.04 "ps -ef" About an hour ago Exited (0) About an hour ago wonderful_archimedes
2285688a10fdf629ca42d55a68c589421cd81955b4ab9e3d29da1e42be470a18 ubuntu:14.04 "echo 'Hello world'" About an hour ago Exited (0) About an hour ago unruffled_bose
root@ird-6-0:~#
root@ird-6-0:~ docker ps -q
3ab87f074a5e
root@ird-6-0:~ docker ps -qa
d9fb65e39bbd
3ab87f074a5e
46341dc98559
b60639a139f1
c7f596997107
8500fd529452
2285688a10fd
root@ird-6-0:~ docker ps -lq
d9fb65e39bbd
root@ird-6-0:~# docker ps -a --filter "exited=0"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d9fb65e39bbd ubuntu:14.04 "echo 'Hello world'" 7 minutes ago Exited (0) 7 minutes ago tender_shaw
46341dc98559 ubuntu:latest "bash" About an hour ago Exited (0) About an hour ago amazing_franklin
b60639a139f1 ubuntu:latest "bash" About an hour ago Exited (0) About an hour ago frosty_darwin
c7f596997107 ubuntu:14.04 "echo 'Hello world'" 2 hours ago Exited (0) 2 hours ago gracious_wozniak
8500fd529452 ubuntu:14.04 "ps -ef" 2 hours ago Exited (0) 2 hours ago wonderful_archimedes
2285688a10fd ubuntu:14.04 "echo 'Hello world'" 2 hours ago Exited (0) 2 hours ago unruffled_bose
root@ird-6-0:~# docker logs 3ab87f074a5e
root@3ab87f074a5e:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@3ab87f074a5e:/# touch test
root@3ab87f074a5e:/#
root@3ab87f074a5e:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys test tmp usr var
root@ird-6-0:~# docker run -d centos:7 ping 127.0.0.1 -c 50
Unable to find image 'centos:7' locally
7: Pulling from library/centos
93857f76ae30: Pull complete
Digest: sha256:4eda692c08e0a065ae91d74e82fff4af3da307b4341ad61fa61771cc4659af60
Status: Downloaded newer image for centos:7
73e9f15a3481800a1457d43189b94c6ad546f802c37ac57ece5e17e0578a1721
root@ird-6-0:~ docker run -d -P nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
6d827a3ef358: Pull complete
f8f2e0556751: Pull complete
5c9972dca3fd: Pull complete
451b9524cb06: Pull complete
Digest: sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582
Status: Downloaded newer image for nginx:latest
bb5e2700e883ea1ad9ebc5d4f1cf6503e5170dd2e3b0b70ae0c8a2d68834ed3b
root@ird-6-0:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bb5e2700e883 nginx "nginx -g 'daemon ..." 14 seconds ago Up 13 seconds 0.0.0.0:32769->80/tcp, 0.0.0.0:32768->443/tcp cranky_fermat
3ab87f074a5e ubuntu:latest "bash" About an hour ago Up About an hour relaxed_banach
# Running an Ubuntu container
root@ird-6-0:~ docker run -i -t ubuntu:latest bash
# Checking the PID number of the bash process then exiting without shutting it down (CTRL + P + Q)
root@cfde79d01b56:/ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 12:26 ? 00:00:00 bash
root 11 1 0 12:27 ? 00:00:00 ps -ef
root@cfde79d01b56:/# root@ird-6-0:~#
# Checking for bash processes and parent id (2nd column)
root@ird-6-0:~ ps -ef | grep bash
root 1172 1107 0 10:20 pts/0 00:00:00 -bash
root 1384 1346 0 10:36 pts/1 00:00:00 -bash
root 2448 2428 0 10:54 pts/2 00:00:00 bash
root 2873 2815 0 12:06 pts/3 00:00:00 -bash
root 3786 3756 0 12:26 pts/4 00:00:00 bash
root 3841 2873 0 12:35 pts/3 00:00:00 grep --color=auto bash
# Checking for dockers processes
root@ird-6-0:~ ps -ef | grep docker-containerd
root 2428 30605 0 10:54 ? 00:00:00 docker-containerd-shim 3ab87f074a5e997a7ae521238c66cd377787f5e145a3e35aa9d5caa40fd3e45b /var/run/docker/libcontainerd/3ab87f074a5e997a7ae521238c66cd377787f5e145a3e35aa9d5caa40fd3e45b docker-runc
root 3641 30605 0 12:20 ? 00:00:00 docker-containerd-shim bb5e2700e883ea1ad9ebc5d4f1cf6503e5170dd2e3b0b70ae0c8a2d68834ed3b /var/run/docker/libcontainerd/bb5e2700e883ea1ad9ebc5d4f1cf6503e5170dd2e3b0b70ae0c8a2d68834ed3b docker-runc
root 3756 30605 0 12:26 ? 00:00:00 docker-containerd-shim cfde79d01b565015565d25738f8ee655f050aefa89ec367bf35adff7c6859e2a /var/run/docker/libcontainerd/cfde79d01b565015565d25738f8ee655f050aefa89ec367bf35adff7c6859e2a docker-runc
root 3843 2873 0 12:35 pts/3 00:00:00 grep --color=auto docker-containerd
root 30605 30598 0 08:43 ? 00:00:25 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
root@ird-6-0:~ pstree -p
systemd(1)─┬─accounts-daemon(1263)─┬─{gdbus}(1293)
│ └─{gmain}(1285)
├─dockerd(30598)─┬─docker-containe(30605)─┬─docker-containe(2428)─┬─bash(2448)
│ │ │ ├─{docker-containe}(2429)
│ │ │ ├─{docker-containe}(2430)
│ │ │ ├─{docker-containe}(2431)
│ │ │ ├─{docker-containe}(2432)
│ │ │ ├─{docker-containe}(2433)
│ │ │ ├─{docker-containe}(2435)
│ │ │ ├─{docker-containe}(2442)
│ │ │ └─{docker-containe}(2443)
│ │ ├─docker-containe(3641)─┬─nginx(3659)───nginx(3684)
│ │ │ ├─{docker-containe}(3642)
│ │ │ ├─{docker-containe}(3643)
│ │ │ ├─{docker-containe}(3644)
│ │ │ ├─{docker-containe}(3645)
│ │ │ ├─{docker-containe}(3646)
│ │ │ ├─{docker-containe}(3647)
│ │ │ ├─{docker-containe}(3649)
│ │ │ └─{docker-containe}(3650)
│ │ ├─docker-containe(3756)─┬─bash(3786)
│ │ │ ├─{docker-containe}(3758)
│ │ │ ├─{docker-containe}(3759)
│ │ │ ├─{docker-containe}(3760)
│ │ │ ├─{docker-containe}(3764)
│ │ │ ├─{docker-containe}(3767)
│ │ │ ├─{docker-containe}(3780)
│ │ │ ├─{docker-containe}(3782)
│ │ │ └─{docker-containe}(3783)
│ │ ├─{docker-containe}(30606)
│ │ ├─{docker-containe}(30607)
│ │ ├─{docker-containe}(30608)
│ │ ├─{docker-containe}(30610)
│ │ ├─{docker-containe}(30611)
│ │ ├─{docker-containe}(30643)
│ │ ├─{docker-containe}(30885)
│ │ ├─{docker-containe}(30887)
│ │ ├─{docker-containe}(1596)
│ │ ├─{docker-containe}(2987)
│ │ └─{docker-containe}(3406)
- docker exec command allows to execute additional processes inside a container
root@ird-6-0:~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bb5e2700e883 nginx "nginx -g 'daemon ..." 23 minutes ago Up 23 minutes 0.0.0.0:32769->80/tcp, 0.0.0.0:32768->443/tcp cranky_fermat
6d17a98cace1 centos:7 "ping 127.0.0.1 -c 50" 26 minutes ago Exited (0) 25 minutes ago wizardly_noether
3ab87f074a5e ubuntu:latest "bash" 2 hours ago Up 2 hours relaxed_banach
root@ird-6-0:~ docker exec -i -t 3ab87f074a5e bash
root@3ab87f074a5e:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys test tmp usr var
root@3ab87f074a5e:/# exit
exit
root@ird-6-0:~ docker stop bb5e2700e883
bb5e2700e883
root@ird-6-0:~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4b8f17028ed9 ubuntu:latest "ping 127.0.0.1 -c 50" 9 minutes ago Created angry_mclean
cfde79d01b56 ubuntu:latest "bash" 22 minutes ago Up 22 minutes flamboyant_agnesi
3ab87f074a5e ubuntu:latest "bash" 2 hours ago Up 2 hours relaxed_banach
docker logs <container name>
root@ird-6-0:~ docker run -d ubuntu:14.04 ping 127.0.0.1 -c 100
7c3ff65d2d4549038c0f4ef8fa691478d7ca41af26d38274262ee814b345c85b
root@ird-6-0:~ docker logs 7c3ff65d2d4549038c0f4ef8fa691478d7ca41af26d38274262ee814b345c85b
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.081 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.114 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.070 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.055 ms
...
# --follow option or -f to get a streaming output from the log
root@ird-6-0:~ docker logs -f 7c3ff65d2d4549038c0f4ef8fa691478d7ca41af26d38274262ee814b345c85b
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.081 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.114 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.070 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.055 ms
...
^C #Hit CTRL + C to stop following the log
#Show the last 10 lines and follow the log
root@ird-6-0:~ docker logs --tail 10 -f 7c3ff65d2d4549038c0f4ef8fa691478d7ca41af26d38274262ee814b345c85b
64 bytes from 127.0.0.1: icmp_seq=36 ttl=64 time=0.086 ms
64 bytes from 127.0.0.1: icmp_seq=37 ttl=64 time=0.077 ms
64 bytes from 127.0.0.1: icmp_seq=38 ttl=64 time=0.053 ms
64 bytes from 127.0.0.1: icmp_seq=39 ttl=64 time=0.067 ms
64 bytes from 127.0.0.1: icmp_seq=40 ttl=64 time=0.056 ms
64 bytes from 127.0.0.1: icmp_seq=41 ttl=64 time=0.066 ms
64 bytes from 127.0.0.1: icmp_seq=42 ttl=64 time=0.069 ms
64 bytes from 127.0.0.1: icmp_seq=43 ttl=64 time=0.067 ms
64 bytes from 127.0.0.1: icmp_seq=44 ttl=64 time=0.100 ms
64 bytes from 127.0.0.1: icmp_seq=45 ttl=64 time=0.084 ms
64 bytes from 127.0.0.1: icmp_seq=46 ttl=64 time=0.067 ms
64 bytes from 127.0.0.1: icmp_seq=47 ttl=64 time=0.095 ms
64 bytes from 127.0.0.1: icmp_seq=48 ttl=64 time=0.545 ms
64 bytes from 127.0.0.1: icmp_seq=49 ttl=64 time=0.075 ms
64 bytes from 127.0.0.1: icmp_seq=50 ttl=64 time=0.055 ms
^A64 bytes from 127.0.0.1: icmp_seq=51 ttl=64 time=0.064 ms
^A64 bytes from 127.0.0.1: icmp_seq=52 ttl=64 time=0.073 ms
64 bytes from 127.0.0.1: icmp_seq=53 ttl=64 time=0.068 ms
64 bytes from 127.0.0.1: icmp_seq=54 ttl=64 time=0.087 ms
64 bytes from 127.0.0.1: icmp_seq=55 ttl=64 time=0.072 ms
^C
root@ird-6-0:~
docker start -a <container ID>
# Run a tomcat container in detached mode
root@ird-6-0:~ docker run -d tomcat
Unable to find image 'tomcat:latest' locally
latest: Pulling from library/tomcat
cd0a524342ef: Pull complete
e39c3ffe4133: Pull complete
aac3320edf40: Pull complete
4d9e109682f7: Pull complete
0a59efcf9553: Pull complete
919cc99a7dac: Pull complete
586ffe6f1b41: Pull complete
ad26c45ead5e: Pull complete
43fcb799397a: Pull complete
3cf960dd1d64: Pull complete
4dbf02149572: Pull complete
6777d7fe003b: Pull complete
2ae9b3d7f905: Pull complete
Digest: sha256:c62b7a6e8da2c07b60d96a0d606369634e901d54f4e9289cba9326f8e3609c8a
Status: Downloaded newer image for tomcat:latest
4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16
# Inspect and follow the container log
root@ird-6-0:~ docker logs -f 4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16
25-Apr-2017 12:59:07.490 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.14
25-Apr-2017 12:59:07.494 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:
...
25-Apr-2017 12:59:07.801 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
25-Apr-2017 12:59:07.848 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
^Z
[1]+ Stopped docker logs -f 4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16
root@ird-6-0:~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4aba76e87bce tomcat "catalina.sh run" 29 seconds ago Up 28 seconds 8080/tcp determined_kilby
7c3ff65d2d45 ubuntu:14.04 "ping 127.0.0.1 -c..." 7 minutes ago Exited (0) 6 minutes ago wonderful_cray
# Stop the container
root@ird-6-0:~ docker stop 4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16
4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16
root@ird-6-0:~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4aba76e87bce tomcat "catalina.sh run" 58 seconds ago Exited (143) 2 seconds ago determined_kilby
7c3ff65d2d45 ubuntu:14.04 "ping 127.0.0.1 -c..." 8 minutes ago Exited (0) 6 minutes ago wonderful_cray
# Start the container again and re-attach to it
root@ird-6-0:~ docker start -a 4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16
25-Apr-2017 13:00:21.193 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.14
25-Apr-2017 13:00:21.198 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Apr 13 2017 12:55:45 UTC
25-Apr-2017 13:00:21.200 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.14.0
25-Apr-2017 13:00:21.200 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
25-Apr-2017 13:00:21.201 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 4.4.0-72-generic
...
root@ird-6-0:~ docker logs --tail 10 -f 4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16
25-Apr-2017 13:02:54.378 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
25-Apr-2017 13:02:54.386 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.1.0e 16 Feb 2017)
25-Apr-2017 13:02:54.598 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
25-Apr-2017 13:02:54.629 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
25-Apr-2017 13:02:54.637 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
^Z
[4]+ Stopped docker logs --tail 10 -f 4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16
root@ird-6-0:~ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4aba76e87bce tomcat "catalina.sh run" 6 minutes ago Up 2 minutes 8080/tcp determined_kilby
cfde79d01b56 ubuntu:latest "bash" 38 minutes ago Up 38 minutes flamboyant_agnesi
[
{
"Id": "4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16",
"Created": "2017-04-25T12:59:05.647558942Z",
"Path": "catalina.sh",
"Args": [
"run"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 5741,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-04-25T13:02:52.851230908Z",
"FinishedAt": "2017-04-25T13:00:50.479530312Z"
},
"Image": "sha256:1f6eab5f63d36f66115d723f85e3140b1b5068ffe3c66a5e83a727d836990394",
"ResolvConfPath": "/var/lib/docker/containers/4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16/hostname",
"HostsPath": "/var/lib/docker/containers/4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16/hosts",
"LogPath": "/var/lib/docker/containers/4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16/4aba76e87bce9029dbd65f297cc1eb3f89886492e98b14134d04f7822a439a16-json.log",
"Name": "/determined_kilby",
"RestartCount": 0,
"Driver": "aufs",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"Config": {
"Hostname": "4aba76e87bce",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"8080/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/tomcat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=C.UTF-8",
"JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre",
"JAVA_VERSION=8u121",
"JAVA_DEBIAN_VERSION=8u121-b13-1~bpo8+1",
"CA_CERTIFICATES_JAVA_VERSION=20161107~bpo8+1",
"CATALINA_HOME=/usr/local/tomcat",
"TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib",
"LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib",
"OPENSSL_VERSION=1.1.0e-1",
"TOMCAT_MAJOR=8",
"TOMCAT_VERSION=8.5.14",
"TOMCAT_TGZ_URL=https://www.apache.org/dyn/closer.cgi?action=download&filename=tomcat/tomcat-8/v8.5.14/bin/apache-tomcat-8.5.14.tar.gz",
"TOMCAT_ASC_URL=https://www.apache.org/dist/tomcat/tomcat-8/v8.5.14/bin/apache-tomcat-8.5.14.tar.gz.asc"
],
"Cmd": [
"catalina.sh",
"run"
],
"ArgsEscaped": true,
"Image": "tomcat",
"Volumes": null,
"WorkingDir": "/usr/local/tomcat",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "1b773719eb15f8f5b6a2bee89e85847a926623a803528d1a94acd4f8078bb073",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"8080/tcp": null
},
"SandboxKey": "/var/run/docker/netns/1b773719eb15",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "2335e75f75c2f19dbc6f6a43c66dcd433789f511c84a45b911667e4c539d5e2e",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:03",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "bb54616150c984116cc181e8c7a34dee298c66dd1621e08901a603e0b5c6a042",
"EndpointID": "2335e75f75c2f19dbc6f6a43c66dcd433789f511c84a45b911667e4c539d5e2e",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:03"
}
}
}
}
]
# Finding a specific property
docker inspect <container name> | grep IPAddress
root@ird-6-0:~ docker inspect --format='{{.Config}}' 4aba76e87bce
{4aba76e87bce false false false map[8080/tcp:{}] false false false [PATH=/usr/local/tomcat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin LANG=C.UTF-8 JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre JAVA_VERSION=8u121 JAVA_DEBIAN_VERSION=8u121-b13-1~bpo8+1 CA_CERTIFICATES_JAVA_VERSION=20161107~bpo8+1 CATALINA_HOME=/usr/local/tomcat TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib OPENSSL_VERSION=1.1.0e-1 GPG_KEYS=05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 713DA88BE50911535FE716F5208B0AB1D63011C7 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23 TOMCAT_MAJOR=8 TOMCAT_VERSION=8.5.14 TOMCAT_TGZ_URL=https://www.apache.org/dyn/closer.cgi?action=download&filename=tomcat/tomcat-8/v8.5.14/bin/apache-tomcat-8.5.14.tar.gz TOMCAT_ASC_URL=https://www.apache.org/dist/tomcat/tomcat-8/v8.5.14/bin/apache-tomcat-8.5.14.tar.gz.asc] [catalina.sh run] <nil> true tomcat map[] /usr/local/tomcat [] false [] map[] <nil> []}
root@ird-6-0:~ docker inspect --format='{{json .Config}}' 4aba76e87bce
{"Hostname":"4aba76e87bce","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":{"8080/tcp":{}},"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/tomcat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","LANG=C.UTF-8","JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre","JAVA_VERSION=8u121","JAVA_DEBIAN_VERSION=8u121-b13-1~bpo8+1","CA_CERTIFICATES_JAVA_VERSION=20161107~bpo8+1","CATALINA_HOME=/usr/local/tomcat","TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib","LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib","OPENSSL_VERSION=1.1.0e-1","GPG_KEYS=05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 713DA88BE50911535FE716F5208B0AB1D63011C7 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23","TOMCAT_MAJOR=8","TOMCAT_VERSION=8.5.14","TOMCAT_TGZ_URL=https://www.apache.org/dyn/closer.cgi?action=download\u0026filename=tomcat/tomcat-8/v8.5.14/bin/apache-tomcat-8.5.14.tar.gz","TOMCAT_ASC_URL=https://www.apache.org/dist/tomcat/tomcat-8/v8.5.14/bin/apache-tomcat-8.5.14.tar.gz.asc"],"Cmd":["catalina.sh","run"],"ArgsEscaped":true,"Image":"tomcat","Volumes":null,"WorkingDir":"/usr/local/tomcat","Entrypoint":null,"OnBuild":null,"Labels":{}}
docker rm -f <container ID>
root@ird-6-0:~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4aba76e87bce tomcat "catalina.sh run" 17 minutes ago Up 13 minutes 8080/tcp determined_kilby
7c3ff65d2d45 ubuntu:14.04 "ping 127.0.0.1 -c..." 24 minutes ago Exited (0) 22 minutes ago wonderful_cray
6eab29ee4ca0 ubuntu:14.04 "ping 127.0.0.1 -c 50" 33 minutes ago Exited (0) 32 minutes ago quizzical_northcutt
f52b385dc1b5 ubuntu:14.04 "ping 127.0.0.1 -c 50" 33 minutes ago Exited (0) 32 minutes ago adoring_dubinsky
5f3934ef5c97 ubuntu:latest "ping 127.0.0.1 -c 50" 33 minutes ago Created youthful_carson
4fab6f1e4d59 ubuntu:14.04 "ping 127.0.0.1 -c 50" 34 minutes ago Exited (0) 33 minutes ago compassionate_sammet
385307d90b44 ubuntu:14.04 "ping 127.0.0.1 -c 50" 36 minutes ago Exited (0) 35 minutes ago pedantic_hermann
4b8f17028ed9 ubuntu:latest "ping 127.0.0.1 -c 50" 36 minutes ago Created
# Delete all containers
root@ird-6-0:~ docker rm -f $(docker ps -aq)
4aba76e87bce
7c3ff65d2d45
6eab29ee4ca0
f52b385dc1b5
5f3934ef5c97
4fab6f1e4d59
385307d90b44
4b8f17028ed9
cfde79d01b56
bb5e2700e883
6d17a98cace1
73e9f15a3481
d9fb65e39bbd
3ab87f074a5e
46341dc98559
b60639a139f1
c7f596997107
8500fd529452
2285688a10fd
root@ird-6-0:~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@ird-6-0:~
docker ps --filter='status=exited'
docker rm <container-id>
docker rm $(docker ps -ql) #running
#Delete all stopped containers
docker rm $(docker ps -aq)
docker system prune
root@ird-6-0:~ docker run -i -t ubuntu:14.04 bash
root@5ce9b596993a:/ apt-get update
Ign http://archive.ubuntu.com trusty InRelease
Get:1 http://archive.ubuntu.com trusty-updates InRelease [65.9 kB]
Get:2 http://archive.ubuntu.com trusty-security InRelease [65.9 kB]
..
Get:21 http://archive.ubuntu.com trusty/restricted amd64 Packages [16.0 kB]
Get:22 http://archive.ubuntu.com trusty/universe amd64 Packages [7589 kB]
Fetched 22.5 MB in 11s (2001 kB/s)
Reading package lists... Done
root@5ce9b596993a:/ apt-get install -y wget vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
ca-certificates libgpm2 libidn11 libpython2.7 libpython2.7-minimal
libpython2.7-stdlib openssl vim-runtime
Suggested packages:
gpm ctags vim-doc vim-scripts
The following NEW packages will be installed:
ca-certificates libgpm2 libidn11 libpython2.7 libpython2.7-minimal
...
root@ird-6-0:~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5ce9b596993a ubuntu:14.04 "bash" 3 minutes ago Exited (0) 22 seconds ago vigilant_agnesi
root@ird-6-0:~ docker diff vigilant_agnesi
C /.wh..wh.plnk
A /.wh..wh.plnk/1001.2052384
A /.wh..wh.plnk/742.2054036
A /.wh..wh.plnk/995.2054023
C /etc
C /etc/alternatives
C /etc/alternatives/editor
C /etc/alternatives/editor.1.gz
C /etc/alternatives/editor.fr.1.gz
C /etc/alternatives/editor.it.1.gz
C /etc/alternatives/editor.ja.1.gz
C /etc/alternatives/editor.pl.1.gz
A add D delete C change
command saves changes in a container as a new image
docker commit [options] [container ID] [repository:tag]
# save container as a image
root@ird-6-0:~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5ce9b596993a ubuntu:14.04 "bash" 9 minutes ago Exited (0) 6 minutes ago vigilant_agnesi
root@ird-6-0:~ docker commit 5ce9b596993a tranchant/myimage:1.0
sha256:06bf6c7e7ce09feb8ce56b9124e30bef57526650f2cfb080f8e0e12020471380
# check that you can see your new image
root@ird-6-0:~ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tranchant/myimage 1.0 06bf6c7e7ce0 6 seconds ago 259MB
tomcat latest 1f6eab5f63d3 12 hours ago 367MB
ubuntu latest f7b3f317ec73 15 hours ago 117MB
ubuntu 14.04 302fa07d8117 12 days ago 188MB
centos 7 a8493f5f50ff 2 weeks ago 192MB
nginx latest 5766334bdaa0 2 weeks ago 183MB
busybox latest 00f017a8c2a6 6 weeks ago 1.11MB
# create a container using the new image
root@ird-6-0:~ docker run -i -t tranchant/myimage:1.0 bash
root@2d7c5086e193:/
# Verify that vim and wget are installed
root@2d7c5086e193:/ vim
root@2d7c5086e193:/ wget
wget: missing URL
Usage: wget [OPTION]... [URL]...
Try `wget --help' for more options.
# Create a file in your container
root@2d7c5086e193:/ touch newFileImage
root@2d7c5086e193:/ ls
bin boot dev etc home lib lib64 media mnt newFileImage opt proc root run sbin srv sys tmp usr var
root@2d7c5086e193:/ exit
exit
root@ird-6-0:~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2d7c5086e193 tranchant/myimage:1.0 "bash" 4 minutes ago Exited (0) 3 minutes ago peaceful_goldwasser
5ce9b596993a ubuntu:14.04 "bash" 16 minutes ago Exited (0) 14 minutes ago vigilant_agnesi
# Commit that as a new image
root@ird-6-0:~ docker commit 2d7c5086e193 tranchant/myimage:1.1
sha256:2bb7abf1ab43de115aef3707611a6a29f137b25072c1ccce39da118d96e46f44
# check image creation
root@ird-6-0:~ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tranchant/myimage 1.1 2bb7abf1ab43 16 seconds ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 7 minutes ago 259MB
tomcat latest 1f6eab5f63d3 13 hours ago 367MB
ubuntu latest f7b3f317ec73 15 hours ago 117MB
ubuntu 14.04 302fa07d8117 12 days ago 188MB
centos 7 a8493f5f50ff 2 weeks ago 192MB
nginx latest 5766334bdaa0 2 weeks ago 183MB
busybox latest 00f017a8c2a6 6 weeks ago 1.11MB
# check the diff between the two lastest version of your image
root@ird-6-0:~ docker diff peaceful_goldwasser
A /newFileImage
C /root
C /root/.bash_history
A /root/.viminfo
root@ird-6-0:~#
#create myimage directory
root@ird-6-0:~# mkdir myimage
root@ird-6-0:~# cd myimage/
root@ird-6-0:~/myimage# vi Dockerfile
root@ird-6-0:~/myimage#
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get install -y wget
- -t followed by the image name
- -f docker_file_name (if the filename is not "Dockerfile")
root@ird-6-0:~/myimage# docker build -t tranchant/mynewimage:1.0 .
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM ubuntu:14.04
---> 302fa07d8117
Step 2/3 : RUN apt-get update
---> Running in eef177eacce6
...
Removing intermediate container eef177eacce6
Step 3/3 : RUN apt-get install -y wget
---> Running in b0dfc152a050
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
ca-certificates libidn11 openssl
...
---> d68b225ac671
Removing intermediate container b0dfc152a050
Successfully built d68b225ac671
root@ird-6-0:~/myimage# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tranchant/mynewimage 1.0 d68b225ac671 About a minute ago 217MB
tranchant/myimage 1.1 2bb7abf1ab43 24 minutes ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 31 minutes ago 259MB
tomcat latest 1f6eab5f63d3 13 hours ago 367MB
ubuntu latest f7b3f317ec73 16 hours ago 117MB
ubuntu 14.04 302fa07d8117 12 days ago 188MB
centos 7 a8493f5f50ff 2 weeks ago 192MB
nginx latest 5766334bdaa0 2 weeks ago 183MB
busybox latest 00f017a8c2a6 6 weeks ago 1.11MB
root@ird-6-0:~/myimage#
root@ird-6-0:~/myimage# docker run -t -i tranchant/mynewimage:1.0 bash
#check whet installed
root@30c389e6dff5:/# wget
wget: missing URL
Usage: wget [OPTION]... [URL]...
Try `wget --help' for more options.
root@30c389e6dff5:/#
# command wget given by command line
root@ird-6-0:~/myimage# docker run tranchant/mynewimage:1.0 wget
wget: missing URL
Usage: wget [OPTION]... [URL]...
Try `wget --help' for more options.
much faster
root@ird-6-0:~/myimage# docker build -t tranchant/mynewimage:1.0 .
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM ubuntu:14.04
---> 302fa07d8117
Step 2/3 : RUN apt-get update
---> Using cache
---> 55ee8e33a42d
Step 3/3 : RUN apt-get install -y wget
---> Using cache
---> d68b225ac671
Successfully built d68b225ac671
root@ird-6-0:~/myimage#
root@ird-6-0:~/myimage# docker build -t tranchant/mynewimage:1.0 .
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM ubuntu:14.04
---> 302fa07d8117
Step 2/3 : RUN apt-get update
---> Using cache
---> 55ee8e33a42d
Step 3/3 : RUN apt-get install -y wget
---> Using cache
---> d68b225ac671
Successfully built d68b225ac671
root@ird-6-0:~/myimage# vi Dockerfile
root@ird-6-0:~/myimage# docker build -t tranchant/mynewimage:1.0 .
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM ubuntu:14.04
---> 302fa07d8117
Step 2/4 : RUN apt-get update
---> Using cache
---> 55ee8e33a42d
Step 3/4 : RUN apt-get install -y wget
---> Using cache
---> d68b225ac671
Step 4/4 : RUN apt-get install -y vim
---> Running in db9cce183ce5
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
libgpm2 libpython2.7 libpython2.7-minimal libpython2.7-stdlib vim-runtime
Suggested packages:
gpm ctags vim-doc vim-scripts
The following NEW packages will be installed:
libgpm2 libpython2.7 libpython2.7-minimal libpython2.7-stdlib vim
vim-runtime
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 9074 kB of archives.
After this operation, 42.9 MB of additional disk space will be used.
...
Processing triggers for libc-bin (2.19-0ubuntu6.11) ...
---> d02c8732fe4c
Removing intermediate container db9cce183ce5
Successfully built d02c8732fe4c
root@ird-6-0:~/myimage#
Before executing a step, Docker checks to see if it has already run that build sequence previously
- If yes, Docker will use the result of that instead of executing the instruction again
- Docker uses exact strings in your Dockerfile to compare with the cache − Simply changing the order of instructions will invalidate the cache
- To disable the cache manually use the --no-cache flag docker build --no-cache -t myimage .
root@ird-6-0:~/myimage# docker build -t tranchant/mynewimage:1.0 .
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM ubuntu:14.04
---> 302fa07d8117
Step 2/3 : RUN apt-get update
---> Using cache
---> 55ee8e33a42d
Step 3/3 : RUN apt-get install -y wget
---> Using cache
---> d68b225ac671
Successfully built d68b225ac671
root@ird-6-0:~/myimage# vi Dockerfile
root@ird-6-0:~/myimage# docker build -t tranchant/mynewimage:1.0 .
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM ubuntu:14.04
---> 302fa07d8117
Step 2/4 : RUN apt-get update
---> Using cache
---> 55ee8e33a42d
Step 3/4 : RUN apt-get install -y wget
---> Using cache
---> d68b225ac671
Step 4/4 : RUN apt-get install -y vim
---> Running in db9cce183ce5
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
libgpm2 libpython2.7 libpython2.7-minimal libpython2.7-stdlib vim-runtime
Suggested packages:
gpm ctags vim-doc vim-scripts
The following NEW packages will be installed:
libgpm2 libpython2.7 libpython2.7-minimal libpython2.7-stdlib vim
vim-runtime
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 9074 kB of archives.
After this operation, 42.9 MB of additional disk space will be used.
...
---> d02c8732fe4c
Removing intermediate container db9cce183ce5
Successfully built d02c8732fe4c
root@ird-6-0:~/myimage# vi Dockerfile
root@ird-6-0:~/myimage# docker build -t tranchant/mynewimage:1.0 .
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM ubuntu:14.04
---> 302fa07d8117
Step 2/4 : RUN apt-get update
---> Using cache
---> 55ee8e33a42d
Step 3/4 : RUN apt-get install -y vim
---> Running in c9361c6199f8
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
libgpm2 libpython2.7 libpython2.7-minimal libpython2.7-stdlib vim-runtime
Suggested packages:
...
Processing triggers for libc-bin (2.19-0ubuntu6.11) ...
---> 270af8d4ddc4
Removing intermediate container c9361c6199f8
Step 4/4 : RUN apt-get install -y wget
---> Running in 418d7760ee00
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
ca-certificates libidn11 openssl
The following NEW packages will be installed:
ca-certificates libidn11 openssl wget
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 1044 kB of archives.
...
Updating certificates in /etc/ssl/certs... 173 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d....done.
---> 5e3ec5deaf88
Removing intermediate container 418d7760ee00
Successfully built 5e3ec5deaf88
root@ird-6-0:~/myimage# vi Dockerfile
docker history
# Getting images id
root@ird-6-0:~/myimage# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tranchant/mynewimage 1.0 5e3ec5deaf88 4 minutes ago 260MB
<none> <none> d02c8732fe4c 6 minutes ago 260MB
tranchant/myimage 1.1 2bb7abf1ab43 About an hour ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 About an hour ago 259MB
tomcat latest 1f6eab5f63d3 13 hours ago 367MB
ubuntu latest f7b3f317ec73 16 hours ago 117MB
ubuntu 14.04 302fa07d8117 12 days ago 188MB
centos 7 a8493f5f50ff 2 weeks ago 192MB
nginx latest 5766334bdaa0 2 weeks ago 183MB
busybox latest 00f017a8c2a6 6 weeks ago 1.11MB
# See history
root@ird-6-0:~/myimage# docker history 5e3ec5deaf88
IMAGE CREATED CREATED BY SIZE COMMENT
5e3ec5deaf88 4 minutes ago /bin/sh -c apt-get install -y wget 6.07MB
270af8d4ddc4 4 minutes ago /bin/sh -c apt-get install -y vim 43.1MB
55ee8e33a42d 29 minutes ago /bin/sh -c apt-get update 22.5MB
302fa07d8117 12 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 12 days ago /bin/sh -c mkdir -p /run/systemd && echo '... 7B
<missing> 12 days ago /bin/sh -c sed -i 's/^#\s*\(deb.*universe\... 1.9kB
<missing> 12 days ago /bin/sh -c rm -rf /var/lib/apt/lists/* 0B
<missing> 12 days ago /bin/sh -c set -xe && echo '#!/bin/sh' >... 195kB
<missing> 12 days ago /bin/sh -c #(nop) ADD file:cd830d3aacc66aa... 188MB
# Compile wget & vim
root@ird-6-0:~/myimage# vi Dockerfile
#Rebuilding
root@ird-6-0:~/myimage# docker build -t tranchant/mynewimage:1.0 .
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM ubuntu:14.04
---> 302fa07d8117
Step 2/3 : RUN apt-get update
---> Using cache
---> 55ee8e33a42d
Step 3/3 : RUN apt-get install -y wget vim
---> Running in a8a314cd1b5b
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
ca-certificates libgpm2 libidn11 libpython2.7 libpython2.7-minimal
libpython2.7-stdlib openssl vim-runtime
Suggested packages:
gpm ctags vim-doc vim-scripts
The following NEW packages will be installed:
ca-certificates libgpm2 libidn11 libpython2.7 libpython2.7-minimal
libpython2.7-stdlib openssl vim vim-runtime wget
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 10.1 MB of archives.
After this operation, 45.3 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libidn11 amd64 1.28-1ubuntu2.1 [94.4 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty/main libgpm2 amd64 1.20.4-6.1 [16.5 kB]
...
Get:8 http://archive.ubuntu.com/ubuntu/ trusty-updates/main wget amd64 1.15-1ubuntu1.14.04.2 [271 kB]
Get:9 http://archive.ubuntu.com/ubuntu/ trusty-updates/main vim-runtime all 2:7.4.052-1ubuntu3.1 [4882 kB]
Get:10 http://archive.ubuntu.com/ubuntu/ trusty-updates/main vim amd64 2:7.4.052-1ubuntu3.1 [955 kB]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
...
dpkg-preconfigure: unable to re-open stdin:
Fetched 10.1 MB in 2s (4498 kB/s)
Selecting previously unselected package libidn11:amd64.
(Reading database ... 11569 files and directories currently installed.)
Preparing to unpack .../libidn11_1.28-1ubuntu2.1_amd64.deb ...
Unpacking libidn11:amd64 (1.28-1ubuntu2.1) ...
Selecting previously unselected package wget.
Preparing to unpack .../wget_1.15-1ubuntu1.14.04.2_amd64.deb ...
Unpacking wget (1.15-1ubuntu1.14.04.2) ...
Selecting previously unselected package vim-runtime.
Preparing to unpack .../vim-runtime_2%3a7.4.052-1ubuntu3.1_all.deb ...
Adding 'diversion of /usr/share/vim/vim74/doc/help.txt to /usr/share/vim/vim74/doc/help.txt.vim-tiny by vim-runtime'
Adding 'diversion of /usr/share/vim/vim74/doc/tags to /usr/share/vim/vim74/doc/tags.vim-tiny by vim-runtime'
Unpacking vim-runtime (2:7.4.052-1ubuntu3.1) ...
Selecting previously unselected package vim.
Preparing to unpack .../vim_2%3a7.4.052-1ubuntu3.1_amd64.deb ...
Unpacking vim (2:7.4.052-1ubuntu3.1) ...
Setting up libidn11:amd64 (1.28-1ubuntu2.1) ...
Setting up libgpm2:amd64 (1.20.4-6.1) ...
Setting up wget (1.15-1ubuntu1.14.04.2) ...
Setting up vim-runtime (2:7.4.052-1ubuntu3.1) ...
Processing /usr/share/vim/addons/doc
Setting up vim (2:7.4.052-1ubuntu3.1) ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
Processing triggers for libc-bin (2.19-0ubuntu6.11) ...
Processing triggers for ca-certificates (20160104ubuntu0.14.04.1) ...
Updating certificates in /etc/ssl/certs... 173 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d....done.
---> d0714b38a665
Removing intermediate container a8a314cd1b5b
Successfully built d0714b38a665
root@ird-6-0:~/myimage# docker history 5e3ec5deaf88
IMAGE CREATED CREATED BY SIZE COMMENT
5e3ec5deaf88 6 minutes ago /bin/sh -c apt-get install -y wget 6.07MB
270af8d4ddc4 6 minutes ago /bin/sh -c apt-get install -y vim 43.1MB
55ee8e33a42d 31 minutes ago /bin/sh -c apt-get update 22.5MB
302fa07d8117 12 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 12 days ago /bin/sh -c mkdir -p /run/systemd && echo '... 7B
<missing> 12 days ago /bin/sh -c sed -i 's/^#\s*\(deb.*universe\... 1.9kB
<missing> 12 days ago /bin/sh -c rm -rf /var/lib/apt/lists/* 0B
<missing> 12 days ago /bin/sh -c set -xe && echo '#!/bin/sh' >... 195kB
<missing> 12 days ago /bin/sh -c #(nop) ADD file:cd830d3aacc66aa... 188MB
root@ird-6-0:~/myimage# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tranchant/mynewimage 1.0 d0714b38a665 49 seconds ago 259MB
<none> <none> 5e3ec5deaf88 6 minutes ago 260MB
<none> <none> d02c8732fe4c 9 minutes ago 260MB
tranchant/myimage 1.1 2bb7abf1ab43 About an hour ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 About an hour ago 259MB
tomcat latest 1f6eab5f63d3 13 hours ago 367MB
ubuntu latest f7b3f317ec73 16 hours ago 117MB
ubuntu 14.04 302fa07d8117 12 days ago 188MB
centos 7 a8493f5f50ff 2 weeks ago 192MB
nginx latest 5766334bdaa0 2 weeks ago 183MB
busybox latest 00f017a8c2a6 6 weeks ago 1.11MB
root@ird-6-0:~/myimage# docker history d0714b38a665
IMAGE CREATED CREATED BY SIZE COMMENT
d0714b38a665 About a minute ago /bin/sh -c apt-get install -y wget vim 48.2MB
55ee8e33a42d 31 minutes ago /bin/sh -c apt-get update 22.5MB
302fa07d8117 12 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 12 days ago /bin/sh -c mkdir -p /run/systemd && echo '... 7B
<missing> 12 days ago /bin/sh -c sed -i 's/^#\s*\(deb.*universe\... 1.9kB
<missing> 12 days ago /bin/sh -c rm -rf /var/lib/apt/lists/* 0B
<missing> 12 days ago /bin/sh -c set -xe && echo '#!/bin/sh' >... 195kB
<missing> 12 days ago /bin/sh -c #(nop) ADD file:cd830d3aacc66aa... 188MB
root@ird-6-0:~/myimage#
FROM ubuntu:14.04
# pour installer package
RUN apt-get update
RUN apt-get install -y wget vim
# pour executer commande qui seront lancées , comportement par defaut de l application qu on demarre par defaut
#CMD ["ping", "127.0.0.1", "-c", "30"]
ENTRYPOINT ["ping"]
# argument
docker build -t tranchant/mynewimage:1.0 .
#docker log
docker run tranchant/mynewimage:1.0 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.096 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.071 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.078 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.055 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.047 ms
64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.084 ms
64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.062 ms
64 bytes from 127.0.0.1: icmp_seq=8 ttl=64 time=0.067 ms
64 bytes from 127.0.0.1: icmp_seq=9 ttl=64 time=0.065 ms
64 bytes from 127.0.0.1: icmp_seq=10 ttl=64 time=0.062 ms
64 bytes from 127.0.0.1: icmp_seq=11 ttl=64 time=0.083 ms
64 bytes from 127.0.0.1: icmp_seq=12 ttl=64 time=0.075 ms
64 bytes from 127.0.0.1: icmp_seq=13 ttl=64 time=
FROM ubuntu:14.04
# pour installer package
RUN apt-get update
RUN apt-get install -y wget vim
# pour executer commande qui seront lancées , comportement par defaut de l application qu on demarre par defaut
#CMD ["ping", "127.0.0.1", "-c", "30"]
# en general lance script shell (ex creation repertoire, set variable environnement avec argument par defaut)
ENTRYPOINT ["ping", "-c", "50"]
# Par defaut lance le CMD comme argument
CMD ["127.0.0.1"]
root@ird-6-0:~/myimage# docker build -t tranchant/mynewimage:1.0 .
Sending build context to Docker daemon 2.048kB
Step 1/5 : FROM ubuntu:14.04
---> 302fa07d8117
Step 2/5 : RUN apt-get update
---> Using cache
---> 55ee8e33a42d
Step 3/5 : RUN apt-get install -y wget vim
---> Using cache
---> d0714b38a665
Step 4/5 : ENTRYPOINT ping -c 50
---> Running in 36a5809821b0
---> fc988242e6c1
Removing intermediate container 36a5809821b0
Step 5/5 : CMD 127.0.0.1
---> Running in aa8fa88c8385
---> 1cb383192409
Removing intermediate container aa8fa88c8385
Successfully built 1cb383192409
root@ird-6-0:~/myimage# docker run tranchant/mynewimage:1.0
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.095 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.084 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.080 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.077 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.279 ms
64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.081 ms
64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.069 ms
^Z64 bytes from 127.0.0.1: icmp_seq=8 ttl=64 time=0.075 ms
64 bytes from 127.0.0.1: icmp_seq=9 ttl=64 time=0.073 ms
64 bytes from 127.0.0.1: icmp_seq=10 ttl=64 time=0.070 ms
^C
--- 127.0.0.1 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 8999ms
rtt min/avg/max/mdev = 0.069/0.098/0.279/0.061 ms
root@ird-6-0:~/myimage# docker run tranchant/mynewimage:1.0 127.0.10.0
PING 127.0.10.0 (127.0.10.0) 56(84) bytes of data.
64 bytes from 127.0.10.0: icmp_seq=1 ttl=64 time=0.093 ms
64 bytes from 127.0.10.0: icmp_seq=2 ttl=64 time=0.062 ms
64 bytes from 127.0.10.0: icmp_seq=3 ttl=64 time=0.084 ms
^Z64 bytes from 127.0.10.0: icmp_seq=4 ttl=64 time=0.076 ms
64 bytes from 127.0.10.0: icmp_seq=5 ttl=64 time=0.109 ms
64 bytes from 127.0.10.0: icmp_seq=6 ttl=64 time=0.081 ms
^C
--- 127.0.10.0 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5000ms
rtt min/avg/max/mdev = 0.062/0.084/0.109/0.015 ms
root@ird-6-0:~/myimage#
#CMD commande en shell => garde les variables SHELL
CMD ["127.0.0.1"]
Syntax jason ou shell => utiliser shell
ENTRYPOINT cmde par defaut
CMD argt par defaut
entrypoint en argument du run : permet overidder entrypoint par defaut
#Setup sample application
# Installation et test coté hote
root@ird-6-0:~# sudo apt-get install openjdk-8-jdk
root@ird-6-0:~# mkdir javahelloworld
root@ird-6-0:~# vi HelloWorld.java
public class HelloWorld
{
public static void main (String [] args)
{
System.out.println("HELLO WORLD");
}
}
root@ird-6-0:~/javahelloworld# vi HelloWorld.java
root@ird-6-0:~/javahelloworld# javac HelloWorld.java
root@ird-6-0:~/javahelloworld# java HelloWorld
HELLO WORLD
root@ird-6-0:~/javahelloworld#
# Dockerize the application
# n the javahelloworld folder, create a Dockerfile
root@ird-6-0:~/javahelloworld# vi Dockerfile
# use java:7 as your base image. This image contains the JDK needed to build and run our application
FROM java:7
# Copy your source file into the container root folder
COPY HelloWorld.java /
# Add an instruction to compile your code
RUN javac HelloWorld.java
#
ENTRYPOINT ["java", "HelloWorld"]
root@ird-6-0:~/javahelloworld# docker build -t tranchant/mynewjava:1.0 .
root@ird-6-0:~/javahelloworld# docker run tranchant/mynewjava:1.0
HELLO WORLD
root@ird-6-0:~/javahelloworld# docker run -it --entrypoint bash tranchant/mynewjava:1.0
root@be4a8ddb4c52:/# ls
HelloWorld.class HelloWorld.java bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@be4a8ddb4c52:/#
# Restructure our application locally, host
root@ird-6-0:~/javahelloworld# ls
Dockerfile HelloWorld.class HelloWorld.java
root@ird-6-0:~/javahelloworld# mkdir src
root@ird-6-0:~/javahelloworld# mkdir bin
root@ird-6-0:~/javahelloworld# mv HelloWorld.java src/
root@ird-6-0:~/javahelloworld# ls
bin Dockerfile HelloWorld.class src
root@ird-6-0:~/javahelloworld# ll
total 24
drwxr-xr-x 4 root root 4096 Apr 26 08:26 ./
drwx------ 6 root root 4096 Apr 26 08:20 ../
drwxr-xr-x 2 root root 4096 Apr 26 08:26 bin/
-rw-r--r-- 1 root root 301 Apr 26 08:20 Dockerfile
-rw-r--r-- 1 root root 425 Apr 26 08:15 HelloWorld.class
drwxr-xr-x 2 root root 4096 Apr 26 08:26 src/
root@ird-6-0:~/javahelloworld# javac -d bin src/HelloWorld.java
root@ird-6-0:~/javahelloworld# ls
bin Dockerfile HelloWorld.class src
root@ird-6-0:~/javahelloworld# ls bin/
HelloWorld.class
root@ird-6-0:~/javahelloworld# java -cp bin HelloWorld
HELLO WORLD
root@ird-6-0:~/javahelloworld#
# Redefine our Dockerfile
root@ird-6-0:~/javahelloworld# vi Dockerfile
# use java:7 as your base image. This image contains the JDK needed to build and run our application
FROM java:7
# Copy your source file into the container root folder
COPY src /home/root/javahelloworld/src
# Add an instruction to compile your code
RUN javac -d bin src/HelloWorld.java
#
ENTRYPOINT ["java", "-cp", "bin", "HelloWorld"]
root@ird-6-0:~/javahelloworld# docker build -t tranchant/mynewjava:1.0 .
Sending build context to Docker daemon 5.12kB
Step 1/4 : FROM java:7
---> 5dc48a6b75af
Step 2/4 : COPY src /home/root/javahelloworld/src
---> 39a4a46c6f66
Removing intermediate container d55624cb71cb
Step 3/4 : RUN javac -d bin src/HelloWorld.java
---> Running in f11c038c4996
javac: file not found: src/HelloWorld.java
Usage: javac <options> <source files>
use -help for a list of possible options
The command '/bin/sh -c javac -d bin src/HelloWorld.java' returned a non-zero code: 2
root@ird-6-0:~/javahelloworld#
root@ird-6-0:~/javahelloworld# vi Dockerfile
# use java:7 as your base image. This image contains the JDK needed to build and run our application
FROM java:7
# Copy your source file into the container root folder
COPY src /home/root/javahelloworld/src
# Add an instruction to compile your code
RUN javac -d bin /home/root/javahelloworld/src/HelloWorld.java
#
ENTRYPOINT ["java", "-cp", "bin", "HelloWorld"]
root@ird-6-0:~/javahelloworld# docker build -t tranchant/mynewjava:1.0 .
Sending build context to Docker daemon 5.12kB
Step 1/4 : FROM java:7
---> 5dc48a6b75af
Step 2/4 : COPY src /home/root/javahelloworld/src
---> Using cache
---> 39a4a46c6f66
Step 3/4 : RUN javac -d bin /home/root/javahelloworld/src/HelloWorld.java
---> Running in d083774b6b8f
---> 17a34a7a5cce
Removing intermediate container d083774b6b8f
Step 4/4 : ENTRYPOINT java -cp bin HelloWorld
---> Running in aea1db0a6eb9
---> bf1fe4d91e25
Removing intermediate container aea1db0a6eb9
Successfully built bf1fe4d91e25
root@ird-6-0:~/javahelloworld# docker run tranchant/mynewjava:1.0
HELLO WORLD
root@ird-6-0:~/javahelloworld#
FROM java:7
WORKDIR /home/root/javahelloworld/
# Copy your source file into the container root folder
COPY src ./src
RUN mkdir bin
# Add an instruction to compile your code
RUN javac -d bin src/HelloWorld.java
#
ENTRYPOINT ["java", "-cp", "bin", "HelloWorld"]
root@ird-6-0:~/javahelloworld# docker build -t tranchant/mynewjava:1.0 .
Sending build context to Docker daemon 5.12kB
Step 1/6 : FROM java:7
---> 5dc48a6b75af
Step 2/6 : WORKDIR /home/root/javahelloworld/
---> Using cache
---> 1a4e121c8e09
Step 3/6 : COPY src ./src
---> 762df88fe10b
Removing intermediate container 62f06c9275ac
Step 4/6 : RUN mkdir bin
---> Running in 994756b7f0de
---> 6fd68eba1c62
Removing intermediate container 994756b7f0de
Step 5/6 : RUN javac -d bin src/HelloWorld.java
---> Running in a2f79ff69261
---> df53959243bb
Removing intermediate container a2f79ff69261
Step 6/6 : ENTRYPOINT java -cp bin HelloWorld
---> Running in 5097b35b5717
---> 0b4cf47b7c50
Removing intermediate container 5097b35b5717
Successfully built 0b4cf47b7c50
root@ird-6-0:~/javahelloworld# docker run tranchant/mynewjava:1.0
HELLO WORLD
root@ird-6-0:~/javahelloworld# docker run -it --entrypoint bash tranchant/mynewjava:1.0
root@08063ee2e640:/home/root/javahelloworld# ls
bin src
root@08063ee2e640:/home/root/javahelloworld# exit
exit
MAINTAINER Docker Training <education@docker.com>
===> balise LABEL
MAINTAINER Docker Training <education@docker.com>
ENV <variable> <value>
ENV JAVA_HOME /usr/bin/java
ENV APP_PORT 8080
# use java:7 as your base image. This image contains the JDK needed to build and run our application
FROM java:7
ENV FOO bar
WORKDIR /home/root/javahelloworld/
# Copy your source file into the container root folder
COPY src ./src
RUN mkdir bin
# Add an instruction to compile your code
RUN javac -d bin src/HelloWorld.java
#
ENTRYPOINT ["java", "-cp", "bin", "HelloWorld"]
root@ird-6-0:~/javahelloworld# docker build -t tranchant/mynewjava:1.0 .
Sending build context to Docker daemon 5.12kB
Step 1/7 : FROM java:7
---> 5dc48a6b75af
Step 2/7 : ENV FOO bar
---> Running in bb862cc61f64
---> 7f8f1e259647
Removing intermediate container bb862cc61f64
Step 3/7 : WORKDIR /home/root/javahelloworld/
---> 7ed30b7b116e
Removing intermediate container 45f75c84159a
Step 4/7 : COPY src ./src
---> 32883cff74c5
Removing intermediate container ccdaf0d9e476
Step 5/7 : RUN mkdir bin
---> Running in 0de4d39e31cd
---> f94650ce5a2a
Removing intermediate container 0de4d39e31cd
Step 6/7 : RUN javac -d bin src/HelloWorld.java
---> Running in e1e6962b5ee5
---> c69ae5bc8e3a
Removing intermediate container e1e6962b5ee5
Step 7/7 : ENTRYPOINT java -cp bin HelloWorld
---> Running in 151409f33a4b
---> 91473d3b8a90
Removing intermediate container 151409f33a4b
Successfully built 91473d3b8a90
root@ird-6-0:~/javahelloworld# docker run -it --entrypoint bash tranchant/mynewjava:1.0
root@8db1474f1eee:/home/root/javahelloworld# echo $FOO
bar
root@8db1474f1eee:/home/root/javahelloworld#
diff avec COPY zippe et dezippe dans le container chemin repertoire ou url
- si fichier lourd, priviligier COPY
root@ird-6-0:~/javahelloworld# docker push javahelloworld:1.0
The push refers to a repository [docker.io/library/javahelloworld]
An image does not exist locally with the tag: javahelloworld
root@ird-6-0:~/javahelloworld# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tranchant/mynewjava 1.0 91473d3b8a90 45 minutes ago 584MB
<none> <none> 0b4cf47b7c50 About an hour ago 584MB
<none> <none> 3d7b25481bda About an hour ago 584MB
<none> <none> bf1fe4d91e25 About an hour ago 584MB
<none> <none> 73facd5d728a About an hour ago 584MB
tranchant/mynewimage 1.0 1cb383192409 2 hours ago 259MB
tranchant/myimage 1.1 2bb7abf1ab43 19 hours ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 20 hours ago 259MB
tomcat latest 1f6eab5f63d3 32 hours ago 367MB
ubuntu latest f7b3f317ec73 35 hours ago 117MB
ubuntu 14.04 302fa07d8117 13 days ago 188MB
centos 7 a8493f5f50ff 2 weeks ago 192MB
nginx latest 5766334bdaa0 2 weeks ago 183MB
busybox latest 00f017a8c2a6 6 weeks ago 1.11MB
java 7 5dc48a6b75af 3 months ago 584MB
root@ird-6-0:~/javahelloworld# docker push mynewjava:1.0
The push refers to a repository [docker.io/library/mynewjava]
An image does not exist locally with the tag: mynewjava
root@ird-6-0:~/javahelloworld# docker tag tranchant/mynewjava:1.0 18092004/javahelloworld:1.0
root@ird-6-0:~/javahelloworld# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
18092004/javahelloworld 1.0 91473d3b8a90 About an hour ago 584MB
tranchant/mynewjava 1.0 91473d3b8a90 About an hour ago 584MB
<none> <none> 0b4cf47b7c50 About an hour ago 584MB
<none> <none> 3d7b25481bda About an hour ago 584MB
<none> <none> bf1fe4d91e25 About an hour ago 584MB
<none> <none> 73facd5d728a About an hour ago 584MB
tranchant/mynewimage 1.0 1cb383192409 2 hours ago 259MB
tranchant/myimage 1.1 2bb7abf1ab43 20 hours ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 20 hours ago 259MB
tomcat latest 1f6eab5f63d3 32 hours ago 367MB
ubuntu latest f7b3f317ec73 35 hours ago 117MB
ubuntu 14.04 302fa07d8117 13 days ago 188MB
centos 7 a8493f5f50ff 2 weeks ago 192MB
nginx latest 5766334bdaa0 2 weeks ago 183MB
busybox latest 00f017a8c2a6 6 weeks ago 1.11MB
java 7 5dc48a6b75af 3 months ago 584MB
root@ird-6-0:~/javahelloworld# docker push 18092004/javahelloworld
The push refers to a repository [docker.io/18092004/javahelloworld]
dadbfdde3fe4: Preparing
43c878681406: Preparing
f48e0cfd316e: Preparing
4cd92a81e3f5: Preparing
869de33b0256: Preparing
61427d9501e8: Waiting
ce6c8756685b: Waiting
30339f20ced0: Waiting
0eb22bfb707d: Waiting
a2ae92ffcd29: Waiting
denied: requested access to the resource is denied
root@ird-6-0:~/javahelloworld# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: 18092004
Password:
Login Succeeded
root@ird-6-0:~/javahelloworld# docker push 18092004/javahelloworld
The push refers to a repository [docker.io/18092004/javahelloworld]
dadbfdde3fe4: Pushed
43c878681406: Pushed
f48e0cfd316e: Pushed
4cd92a81e3f5: Pushed
869de33b0256: Pushed
61427d9501e8: Pushed
ce6c8756685b: Pushed
30339f20ced0: Pushed
0eb22bfb707d: Pushed
a2ae92ffcd29: Pushed
1.0: digest: sha256:31bec2da6af0124eb22271788394ab932477dfa44e8d235a5c79548c3e4ccd74 size: 2411
### ADD a command RUN
# use java:7 as your base image. This image contains the JDK needed to build and run our application
FROM java:7
ENV FOO bar
WORKDIR /home/root/javahelloworld/
# Copy your source file into the container root folder
COPY src ./src
RUN mkdir bin
# Add an instruction to compile your code
RUN javac -d bin src/HelloWorld.java
RUN touch test
#
ENTRYPOINT ["java", "-cp", "bin", "HelloWorld"]
root@ird-6-0:~/javahelloworld# docker build -t 18092004/javahelloworld:1.1 .
Sending build context to Docker daemon 5.12kB
Step 1/8 : FROM java:7
---> 5dc48a6b75af
Step 2/8 : ENV FOO bar
---> Using cache
---> 7f8f1e259647
Step 3/8 : WORKDIR /home/root/javahelloworld/
---> Using cache
---> 7ed30b7b116e
Step 4/8 : COPY src ./src
---> Using cache
---> 32883cff74c5
Step 5/8 : RUN mkdir bin
---> Using cache
---> f94650ce5a2a
Step 6/8 : RUN javac -d bin src/HelloWorld.java
---> Using cache
---> c69ae5bc8e3a
Step 7/8 : RUN touch test
---> Running in 5fccab754346
---> 3cdb96e55f38
Removing intermediate container 5fccab754346
Step 8/8 : ENTRYPOINT java -cp bin HelloWorld
---> Running in 23b4f8a15de4
---> a6121ec6a6c4
Removing intermediate container 23b4f8a15de4
Successfully built a6121ec6a6c4
root@ird-6-0:~/javahelloworld# docker push 18092004/javahelloworld
The push refers to a repository [docker.io/18092004/javahelloworld]
dadbfdde3fe4: Layer already exists
43c878681406: Layer already exists
f48e0cfd316e: Layer already exists
4cd92a81e3f5: Layer already exists
869de33b0256: Layer already exists
61427d9501e8: Layer already exists
ce6c8756685b: Layer already exists
30339f20ced0: Layer already exists
0eb22bfb707d: Layer already exists
a2ae92ffcd29: Layer already exists
1.0: digest: sha256:31bec2da6af0124eb22271788394ab932477dfa44e8d235a5c79548c3e4ccd74 size: 2411
8676dc873f68: Pushed
dadbfdde3fe4: Layer already exists
43c878681406: Layer already exists
f48e0cfd316e: Layer already exists
4cd92a81e3f5: Layer already exists
869de33b0256: Layer already exists
61427d9501e8: Layer already exists
ce6c8756685b: Layer already exists
30339f20ced0: Layer already exists
0eb22bfb707d: Layer already exists
a2ae92ffcd29: Layer already exists
1.1: digest: sha256:a8d0e72ccca61d188e6597b0ed4fea8b37d46e8bed58bdf80f0c2319aa601c87 size: 2618
root@ird-6-0:~/javahelloworld#
#### Cree juste nouveau layer et pousse juste le nouveau layer
### CREE REPO PRIVE
root@ird-6-0:~/javahelloworld# docker pull guignon/myapplication
Using default tag: latest
Error response from daemon: repository guignon/myapplication not found: does not exist or no pull access
root@ird-6-0:~/javahelloworld# docker pull guignon/myapplication:1.0
1.0: Pulling from guignon/myapplication
8f229c550c2e: Already exists
8e1fb71e8df6: Already exists
f75a34586856: Already exists
8744e322b832: Already exists
d5165bfce78f: Already exists
031499d41729: Pull complete
9e2356077fd1: Pull complete
Digest: sha256:eb2ab3b714df4290f523def2aaa80f805031fd381efe6c8a40319c8663cc9db5
Status: Downloaded newer image for guignon/myapplication:1.0
root@ird-6-0:~/javahelloworld#
docker rmi [repo:tag]
root@ird-6-0:~/javahelloworld# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
18092004/javahelloworld 1.1 a6121ec6a6c4 16 minutes ago 584MB
18092004/javahelloworld 1.0 91473d3b8a90 About an hour ago 584MB
tranchant/mynewjava 1.0 91473d3b8a90 About an hour ago 584MB
guignon/javahello 1.0 68e0a0ef57dc About an hour ago 643MB
<none> <none> 0b4cf47b7c50 About an hour ago 584MB
<none> <none> 3d7b25481bda About an hour ago 584MB
<none> <none> bf1fe4d91e25 2 hours ago 584MB
<none> <none> 73facd5d728a 2 hours ago 584MB
tranchant/mynewimage 1.0 1cb383192409 2 hours ago 259MB
guignon/myapplication 1.0 05dfc9866def 2 hours ago 259MB
<none> <none> 29d150b1bfed 2 hours ago 259MB
<none> <none> 227336e84e7a 2 hours ago 259MB
<none> <none> 5e3ec5deaf88 19 hours ago 260MB
<none> <none> d02c8732fe4c 19 hours ago 260MB
tranchant/myimage 1.1 2bb7abf1ab43 20 hours ago 259MB
18092004/myimage 1.0 06bf6c7e7ce0 20 hours ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 20 hours ago 259MB
tomcat latest 1f6eab5f63d3 33 hours ago 367MB
ubuntu latest f7b3f317ec73 35 hours ago 117MB
ubuntu 14.04 302fa07d8117 13 days ago 188MB
centos 7 a8493f5f50ff 2 weeks ago 192MB
nginx latest 5766334bdaa0 2 weeks ago 183MB
busybox latest 00f017a8c2a6 6 weeks ago 1.11MB
java 7 5dc48a6b75af 3 months ago 584MB
root@ird-6-0:~/javahelloworld# docker rmi guignon/myapplication:1.0
Untagged: guignon/myapplication:1.0
Untagged: guignon/myapplication@sha256:eb2ab3b714df4290f523def2aaa80f805031fd381efe6c8a40319c8663cc9db5
Deleted: sha256:05dfc9866defde6bfcb708e67f6bf4fb087da5ab3f4fad3e5c60755fb241fb5a
Deleted: sha256:1ca5ba955bb78579fe320dfec7f092db59569e5fd1866e6c53de736ebc1fbaeb
Deleted: sha256:8c80a4e016543202c65b0682e84dc1213cf76aef1cecd4f13d0e408f1dd0dd7c
root@ird-6-0:~/javahelloworld# docker rmi guignon/javahello
guignon/javahello guignon/javahello:1.0
root@ird-6-0:~/javahelloworld# docker rmi guignon/javahello:1.0
Untagged: guignon/javahello:1.0
Untagged: guignon/javahello@sha256:921cb31a0033a38f34a877e22240e46bfb78a678e2e6dcf523abdbae5493e29b
Deleted: sha256:68e0a0ef57dcf4cca2973f9010fdf5e97cde1828d711c3361403e5b08071d38e
Deleted: sha256:63ba0315faeb98fe7c83bb537f383799af9d99146321218671c23287af7abd36
Deleted: sha256:0bd84b826db540c8ce0c853ca5428810aff027aaca07ea41e5d313d5747e41b2
Deleted: sha256:0804178f7212958e6152fcc00ecda3e4ebb029a02cabf8273699467d00e4b406
Deleted: sha256:0132aeca1bc9ac49d397635d34675915693a8727b103639ddee3cc5438e0f60a
Deleted: sha256:c011315277e16e6c88687a6c683e388e2879f9a195113129a2ca12f782d9fcf9
Deleted: sha256:3181aa7c07970b525de9d3bd15c4c3710a2ab49fd5927df41e5586d9b89b1480
Deleted: sha256:b0053647bc72f97b7a9709a505a20a7a74a556c6aa025979e36532ff3df7cb8d
root@ird-6-0:~/javahelloworld#
- a designated directory in a container, which is designed to persist data, independent of the container’s life cycle
root@ird-6-0:~/javahelloworld# docker volume create --name test1
test1
root@ird-6-0:~/javahelloworld# docker volume ls
DRIVER VOLUME NAME
local test1
root@ird-6-0:~/javahelloworld# docker run -it -v test1:/www/website ubuntu:14.04 bash
root@5b67d22a81b2:/# cd /www/website/
root@5b67d22a81b2:/www/website# ls
root@5b67d22a81b2:/www/website# touch test.txt
root@5b67d22a81b2:/www/website# root@ird-6-0:~/javahelloworld# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5b67d22a81b2 ubuntu:14.04 "bash" 46 seconds ago Up 45 seconds stupefied_heyrovsky
97a0b1a56ad9 nginx "nginx -g 'daemon ..." 14 hours ago Up 14 hours 80/tcp, 443/tcp elated_bose
190eecb7b362 ubuntu:latest "bash" 17 hours ago Up 17 hours nifty_neumann
root@ird-6-0:~/javahelloworld# docker commit 5b67d22a81b2 test:1.0
sha256:dc66e7a6ac8845f233b6a33510da246f38239ad73c84f44851a71af5a5866732
root@ird-6-0:~/javahelloworld# docker run -it test
test test:1.0
root@ird-6-0:~/javahelloworld# docker run -it test
test test:1.0
root@ird-6-0:~/javahelloworld# docker run -it test:1.0 bash
root@de921fee5cdd:/# cd /www/website/
root@de921fee5cdd:/www/website# ls
root@de921fee5cdd:/www/website# exit
exit
root@ird-6-0:~/javahelloworld# ps
PID TTY TIME CMD
5281 pts/1 00:00:00 ps
32323 pts/1 00:00:01 bash
root@ird-6-0:~/javahelloworld# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5b67d22a81b2 ubuntu:14.04 "bash" About a minute ago Up About a minute stupefied_heyrovsky
97a0b1a56ad9 nginx "nginx -g 'daemon ..." 14 hours ago Up 14 hours 80/tcp, 443/tcp elated_bose
190eecb7b362 ubuntu:latest "bash" 17 hours ago Up 17 hours nifty_neumann
root@ird-6-0:~/javahelloworld# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test 1.0 dc66e7a6ac88 About a minute ago 188MB
18092004/javahelloworld 1.1 a6121ec6a6c4 39 minutes ago 584MB
18092004/javahelloworld 1.0 91473d3b8a90 2 hours ago 584MB
tranchant/mynewjava 1.0 91473d3b8a90 2 hours ago 584MB
<none> <none> 0b4cf47b7c50 2 hours ago 584MB
<none> <none> 3d7b25481bda 2 hours ago 584MB
<none> <none> bf1fe4d91e25 2 hours ago 584MB
<none> <none> 73facd5d728a 2 hours ago 584MB
tranchant/mynewimage 1.0 1cb383192409 3 hours ago 259MB
<none> <none> 29d150b1bfed 3 hours ago 259MB
<none> <none> 227336e84e7a 3 hours ago 259MB
<none> <none> 5e3ec5deaf88 20 hours ago 260MB
<none> <none> d02c8732fe4c 20 hours ago 260MB
tranchant/myimage 1.1 2bb7abf1ab43 20 hours ago 259MB
18092004/myimage 1.0 06bf6c7e7ce0 20 hours ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 20 hours ago 259MB
tomcat latest 1f6eab5f63d3 33 hours ago 367MB
ubuntu latest f7b3f317ec73 36 hours ago 117MB
ubuntu 14.04 302fa07d8117 13 days ago 188MB
centos 7 a8493f5f50ff 2 weeks ago 192MB
nginx latest 5766334bdaa0 2 weeks ago 183MB
busybox latest 00f017a8c2a6 6 weeks ago 1.11MB
java 7 5dc48a6b75af 3 months ago 584MB
root@ird-6-0:~/javahelloworld# docker inspect test1
[
{
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/test1/_data",
"Name": "test1",
"Options": {},
"Scope": "local"
}
]
root@ird-6-0:~/javahelloworld# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5b67d22a81b2 ubuntu:14.04 "bash" 12 minutes ago Up 12 minutes stupefied_heyrovsky
97a0b1a56ad9 nginx "nginx -g 'daemon ..." 14 hours ago Up 14 hours 80/tcp, 443/tcp elated_bose
190eecb7b362 ubuntu:latest "bash" 17 hours ago Up 17 hours nifty_neumann
root@ird-6-0:~/javahelloworld# docker inspect 5b67d22a81b2
[
{
"Id": "5b67d22a81b2d3185f861ae85a59a7236a4cd51665bed842faccf7e1ba69705a",
"Created": "2017-04-26T10:28:46.608478705Z",
"Path": "bash",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 4939,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-04-26T10:28:47.14221237Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:302fa07d8117297adb599cc4ed7400348de5fe0f7950291e4bc32938324371b2",
"ResolvConfPath": "/var/lib/docker/containers/5b67d22a81b2d3185f861ae85a59a7236a4cd51665bed842faccf7e1ba69705a/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/5b67d22a81b2d3185f861ae85a59a7236a4cd51665bed842faccf7e1ba69705a/hostname",
"HostsPath": "/var/lib/docker/containers/5b67d22a81b2d3185f861ae85a59a7236a4cd51665bed842faccf7e1ba69705a/hosts",
"LogPath": "/var/lib/docker/containers/5b67d22a81b2d3185f861ae85a59a7236a4cd51665bed842faccf7e1ba69705a/5b67d22a81b2d3185f861ae85a59a7236a4cd51665bed842faccf7e1ba69705a-json.log",
"Name": "/stupefied_heyrovsky",
"RestartCount": 0,
"Driver": "aufs",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
...
"Mounts": [
{
"Type": "volume",
"Name": "test1",
"Source": "/var/lib/docker/volumes/test1/_data",
"Destination": "/www/website",
"Driver": "local",
"Mode": "z",
"RW": true,
"Propagation": ""
}
],...
}
}
}
}
]
root@ird-6-0:~/javahelloworld# cd /var/lib/docker/volumes/test1/_data
root@ird-6-0:/var/lib/docker/volumes/test1/_data# ls
test.txt
root@ird-6-0:/var/lib/docker/volumes/test1/_data# touch test2.txt
root@ird-6-0:/var/lib/docker/volumes/test1/_data# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5b67d22a81b2 ubuntu:14.04 "bash" 15 minutes ago Up 15 minutes stupefied_heyrovsky
97a0b1a56ad9 nginx "nginx -g 'daemon ..." 15 hours ago Up 15 hours 80/tcp, 443/tcp elated_bose
root@ird-6-0:/var/lib/docker/volumes/test1/_data# docker exec -it 5b67d22a81b2 bash
root@5b67d22a81b2:/# ls /www/website/
test.txt test2.txt
- Delete the volume called test1
docker volume rm test1
- Delete a container and remove it’s associated volumes
docker rm -v <container ID>
root@ird-6-0:~# docker rm -f 5b67d22a81b2
5b67d22a81b2
root@ird-6-0:~# docker volume ls
DRIVER VOLUME NAME
local test1
root@ird-6-0:~# ls /var/lib/docker/volumes/test1/_data/
test2.txt test.txt
root@ird-6-0:~# docker volume rm test1
Error response from daemon: unable to remove volume: remove test1: volume is in use - [4140806a3be8a5612267184428235f60d08d7ecd5c3c6d1087e9d56f8836a543, da2e99b5dffa236e75190db030e8706fb9733cbcbf6969347719f02bac65670f]
root@ird-6-0:~# docker rm 4140806a3be8a5612267184428235f60d08d7ecd5c3c6d1087e9d56f8836a543
4140806a3be8a5612267184428235f60d08d7ecd5c3c6d1087e9d56f8836a543
root@ird-6-0:~# docker rm da2e99b5dffa236e75190db030e8706fb9733cbcbf6969347719f02bac65670f
da2e99b5dffa236e75190db030e8706fb9733cbcbf6969347719f02bac65670f
root@ird-6-0:~# docker volume rm test1
test1
root@ird-6-0:~# docker volume ls
DRIVER VOLUME NAME
docker run -v [host path]:[container path]:[rw|ro]
# Mount the contents of the public_html folder on the hosts to the container volume at /data/www
root@ird-6-0:~# mkdir public_html
root@ird-6-0:~# touch public_html/index.html
# Run an Ubuntu container and mount the public_html folder to the volume /data/www
root@ird-6-0:~# docker run -it -v /root/public_html/:/data/www ubuntu:14.04 bash
root@5861b11da622:/# ls /data/www/
index.html
#Exit the container without stopping it CTRL + P + Q
# Modify the index.html file on the host by adding some new lines
root@ird-6-0:~# root@ird-6-0:~# vi public_html/index.html
root@ird-6-0:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5861b11da622 ubuntu:14.04 "bash" 3 minutes ago Up 3 minutes serene_liskov
97a0b1a56ad9 nginx "nginx -g 'daemon ..." 16 hours ago Up 16 hours 80/tcp, 443/tcp elated_bose
190eecb7b362 ubuntu:latest "bash" 19 hours ago Up 19 hours nifty_neumann
#Attach to the container and check the index.html file inside /data/www
for the changes
root@ird-6-0:~# docker attach 5861b11da622
root@5861b11da622:/#
root@5861b11da622:/# ls
bin boot data dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@5861b11da622:/# ls /data/www/
index.html
- A data persistence example with NGINX
# Create a volume called nginx_logs
root@ird-6-0:~# docker volume create --name nginx_logs
nginx_logs
# Run the custom trainingteam/nginx container and map your public_html folder to a volume at /usr/share/nginx/html.
# Also mount your nginx_logs volume to the /var/log/nginx folder. Name the container nginx_server
root@ird-6-0:~# ls public_html/
index.html
# run container
root@ird-6-0:~# docker run -d -P --name nginx_server -v /root/public_html:/usr/share/nginx/html -v nginx_logs:/var/log/nginx trainingteam/nginx
97b6f63df6a5d301c74589d473896d5e301cef6512f79316c0f33db4b0935442
# Get terminal access to your container
root@ird-6-0:~# docker exec -it nginx_server bash
root@97b6f63df6a5:/# cd /usr/share/nginx/html/
root@97b6f63df6a5:/usr/share/nginx/html# ls
index.html
root@97b6f63df6a5:/usr/share/nginx/html# exit
exit
root@ird-6-0:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
97b6f63df6a5 trainingteam/nginx "nginx -g 'daemon ..." 45 seconds ago Up 44 seconds 0.0.0.0:32779->80/tcp, 0.0.0.0:32778->443/tcp nginx_server
97a0b1a56ad9 nginx "nginx -g 'daemon ..." 16 hours ago Up 16 hours 80/tcp, 443/tcp elated_bose
190eecb7b362 ubuntu:latest "bash" 19 hours ago Up 19 hours nifty_neumann
root@ird-6-0:~# docker exec -it nginx_server bash
root@97b6f63df6a5:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@97b6f63df6a5:/# exit
exit
root@ird-6-0:~# vi public_html/index.html
root@ird-6-0:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
97b6f63df6a5 trainingteam/nginx "nginx -g 'daemon ..." 3 minutes ago Up 3 minutes 0.0.0.0:32779->80/tcp, 0.0.0.0:32778->443/tcp nginx_server
97a0b1a56ad9 nginx "nginx -g 'daemon ..." 16 hours ago Up 16 hours 80/tcp, 443/tcp elated_bose
190eecb7b362 ubuntu:latest "bash" 19 hours ago Up 19 hours nifty_neumann
root@ird-6-0:~# docker exec -it nginx_server bash
root@97b6f63df6a5:/# cd /var/log/nginx/
root@97b6f63df6a5:/var/log/nginx# ls
access.log error.log
root@97b6f63df6a5:/var/log/nginx# less error.log
bash: less: command not found
root@97b6f63df6a5:/var/log/nginx# vi error.log
bash: vi: command not found
root@97b6f63df6a5:/var/log/nginx# cat error.log
2017/04/26 12:39:09 [error] 5#5: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 80.215.220.112, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "159.203.67.250:32779", referrer: "http://159.203.67.250:32779/"
root@97b6f63df6a5:/var/log/nginx# cat access.log
80.215.220.112 - - [26/Apr/2017:12:39:08 +0000] "GET / HTTP/1.1" 200 29 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Safari/537.36" "-"
80.215.220.112 - - [26/Apr/2017:12:39:09 +0000] "GET /favicon.ico HTTP/1.1" 404 571 "http://159.203.67.250:32779/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Safari/537.36" "-"
80.215.220.112 - - [26/Apr/2017:12:40:19 +0000] "GET / HTTP/1.1" 200 51 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Safari/537.36" "-"
root@97b6f63df6a5:/var/log/nginx# exit
exit
root@ird-6-0:~# docker volume inspect nginx_logs nginx_logs
[
{
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/nginx_logs/_data",
"Name": "nginx_logs",
"Options": {},
"Scope": "local"
},
{
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/nginx_logs/_data",
"Name": "nginx_logs",
"Options": {},
"Scope": "local"
}
]
root@ird-6-0:~# less /var/lib/docker/volumes/nginx_logs/_data/
access.log error.log
root@ird-6-0:~# less /var/lib/docker/volumes/nginx_logs/_data/error.log
root@ird-6-0:~# tail -f /var/lib/docker/volumes/nginx_logs/_data/access.log
80.215.220.112 - - [26/Apr/2017:12:39:08 +0000] "GET / HTTP/1.1" 200 29 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Safari/537.36" "-"
80.215.220.112 - - [26/Apr/2017:12:39:09 +0000] "GET /favicon.ico HTTP/1.1" 404 571 "http://159.203.67.250:32779/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Safari/537.36" "-"
80.215.220.112 - - [26/Apr/2017:12:40:19 +0000] "GET / HTTP/1.1" 200 51 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Safari/537.36" "-"
80.215.220.112 - - [26/Apr/2017:12:42:17 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Safari/537.36" "-"
^Z
[1]+ Stopped tail -f /var/lib/docker/volumes/nginx_logs/_data/access.log
root@ird-6-0:~#
#make sure that your nginx_server container from EX8.6 is still running
# Run an Ubuntu container and mount the nginx_logs volume to the folder /data/mylogs as read only.
# Run bash as your process.
root@ird-6-0:~ docker run -it -v nginx_logs:/data/mylogs:ro ubuntu:14.04 bash
#On your container terminal, change directory to /data/mylogs
#we can see the access.log and error.log files
root@935c32aa13d9:/# ls /data/mylogs/
access.log error.log
root@935c32aa13d9:/# tail -f /data/mylogs/access.log
80.215.220.112 - - [26/Apr/2017:12:39:08 +0000] "GET / HTTP/1.1" 200 29 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Safari/537.36" "-"
80.215.220.112 - - [26/Apr/2017:12:39:09 +0000] "GET /favicon.ico HTTP/1.1" 404 571 "http://159.203.67.250:32779/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Safari/537.36" "-"
80.215.220.112 - - [26/Apr/2017:12:40:19 +0000] "GET / HTTP/1.1" 200 51 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Safari/537.36" "-"
80.215.220.112 - - [26/Apr/2017:12:42:17 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Safari/537.36" "-"
Â^Z
[1]+ Stopped tail -f /data/mylogs/access.log
# Try and create a new file called text.txt touch test.txt
# Notice how it fails because we mounted the volume as read only
root@935c32aa13d9:/# touch /data/mylogs/test.txt
touch: cannot touch '/data/mylogs/test.txt': Read-only file system
1. Open your Dockerfile in the myimage folder
2. Delete or comment out the CMD and ENTRYPOINT instructions
3. Add an instruction to create a folder /data/myvol RUN mkdir /data/myvol -p
4. Add an instruction to create a file called test inside /data/myvol RUN echo “put some text here” > /data/myvol/test
5. Define a volume at /data/myvol VOLUME /data/myvol
6. Build the image and tag as 1.1 docker build -t myimage:1.1 .
7. Run a container from the image and specify a bash terminal as your process
8. Check the /data/myvol folder and verify that your file is present
- Docker comes with three networks automatically setup
- The bridge network is the docker0 bridge
- By default all containers are connected to the bridge network
student@dockerhost:~$ docker network ls
NETWORK ID
d1dc8ce401a4
123297c4b101
ec95beed1ab7
NAME DRIVER
bridge bridge
none null
host host
root@ird-6-0:~# docker stop $(docker ps -aq)
935c32aa13d9
76306ea709d2
97b6f63df6a5
5861b11da622
root@ird-6-0:~# docker run --name=ubuntu1 -d -it ubuntu:14.04
a83bc1d603a15931d042594ba77deb68829beddb17d32473ca5c4f1838035220
root@ird-6-0:~# docker network inspect bridge
[
{
"Name": "bridge",
"Id": "bb54616150c984116cc181e8c7a34dee298c66dd1621e08901a603e0b5c6a042",
"Created": "2017-04-25T08:43:12.815891614Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Containers": {
"a83bc1d603a15931d042594ba77deb68829beddb17d32473ca5c4f1838035220": {
"Name": "ubuntu1",
"EndpointID": "068f4dda77cefe6ea10221b70fb1130d7938bcdd1f5efef25ce5af737f0a377a",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
root@ird-6-0:~# docker run --name=ubuntu2 -it ubuntu:14.04 bash
root@a7db47e51868:/# ping 172.17.0.2
PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data.
64 bytes from 172.17.0.2: icmp_seq=1 ttl=64 time=0.241 ms
64 bytes from 172.17.0.2: icmp_seq=2 ttl=64 time=0.407 ms
64 bytes from 172.17.0.2: icmp_seq=3 ttl=64 time=0.089 ms
^Z
[1]+ Stopped ping 172.17.0.2
root@a7db47e51868:/# ping ubuntu1
ping: unknown host ubuntu1
root@a7db47e51868:/# root@ird-6-0:~#
root@a7db47e51868:/# network inspect bridge -it ubuntu:14.04 bash
[
{
"Name": "bridge",
"Id": "bb54616150c984116cc181e8c7a34dee298c66dd1621e08901a603e0b5c6a042",
"Created": "2017-04-25T08:43:12.815891614Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Containers": {
"a7db47e51868e16e8bff42a061d1bb29b1d34fa1226a0d01ee9af200e4fafc20": {
"Name": "ubuntu2",
"EndpointID": "d7674eee8f343ba2ad9c46bc5ae5441d0a9f002d11c64ee9bdc3a6c68311cc7f",
"MacAddress": "02:42:ac:11:00:03",
"IPv4Address": "172.17.0.3/16",
"IPv6Address": ""
},
"a83bc1d603a15931d042594ba77deb68829beddb17d32473ca5c4f1838035220": {
"Name": "ubuntu1",
"EndpointID": "068f4dda77cefe6ea10221b70fb1130d7938bcdd1f5efef25ce5af737f0a377a",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
root@ird-6-0:~#
Two types of networks can be created :
- A bridge network is very similar to the docker0 network (the default bridge network we’ve seen)
- An Overlay network can span across multiple hosts
- Use the
--driver
option indocker network create
docker network create --driver bridge my_bridge
- launch a container with this a specified bridge
docker run -d -it --net=bridge_name --name container_name ubuntu:14.04
# Create a new bridge network called my_bridge
root@ird-6-0:~# docker network create --driver bridge my_bridge
ded4841859fd644ec6b926d45d43f7ec02a1f2557908c5855126e769e43b3c52
# Verify the network was successfully created by running
root@ird-6-0:~# docker network ls
NETWORK ID NAME DRIVER SCOPE
bb54616150c9 bridge bridge local
11d63bd3106c host host local
ded4841859fd my_bridge bridge local
691b702b8f08 none null local
# Launch an Ubuntu container (called ubuntu3) in the background on the my_bridge network
root@ird-6-0:~# docker run -d -it --net=my_bridge --name ubuntu3 ubuntu:14.04
90060b15d155bb433bb4ceb3e1df5e0ce366490c892d0237747e43f742b32276
# Launch an Ubuntu container (called ubuntu4) in the background on the my_bridge network
root@ird-6-0:~# docker run -it --net=my_bridge --name ubuntu4 ubuntu:14.04
# Try to ping the ubuntu1 or ubuntu2 containers from Exercise 9.1
# those containers are on a different network and we will get no response
root@a21005c93880:/# ping ubuntu1
ping: unknown host ubuntu1
root@a21005c93880:/# ping ubuntu2
ping: unknown host ubuntu2
root@a21005c93880:/# ping ubuntu3
PING ubuntu3 (172.18.0.2) 56(84) bytes of data.
64 bytes from ubuntu3.my_bridge (172.18.0.2): icmp_seq=1 ttl=64 time=0.188 ms
64 bytes from ubuntu3.my_bridge (172.18.0.2): icmp_seq=2 ttl=64 time=0.108 ms
^Z
[1]+ Stopped ping ubuntu3
root@a21005c93880:/# ping ubuntu4
PING ubuntu4 (172.18.0.3) 56(84) bytes of data.
64 bytes from a21005c93880 (172.18.0.3): icmp_seq=1 ttl=64 time=0.074 ms
64 bytes from a21005c93880 (172.18.0.3): icmp_seq=2 ttl=64 time=0.716 ms
^Z
[2]+ Stopped ping ubuntu4
root@a21005c93880:/# exit
exit
There are stopped jobs.
root@a21005c93880:/# exit
exit
root@ird-6-0:~#
docker network connect [network name] [container name]
# Connect ubuntu2 container to the my_bridge network
root@ird-6-0:~# docker network connect my_bridge ubuntu2
root@ird-6-0:~# docker network inspect bridge
[
{
"Name": "bridge",
"Id": "bb54616150c984116cc181e8c7a34dee298c66dd1621e08901a603e0b5c6a042",
"Created": "2017-04-25T08:43:12.815891614Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Containers": {
"a7db47e51868e16e8bff42a061d1bb29b1d34fa1226a0d01ee9af200e4fafc20": {
"Name": "ubuntu2",
"EndpointID": "d7674eee8f343ba2ad9c46bc5ae5441d0a9f002d11c64ee9bdc3a6c68311cc7f",
"MacAddress": "02:42:ac:11:00:03",
"IPv4Address": "172.17.0.3/16",
"IPv6Address": ""
},
"a83bc1d603a15931d042594ba77deb68829beddb17d32473ca5c4f1838035220": {
"Name": "ubuntu1",
"EndpointID": "068f4dda77cefe6ea10221b70fb1130d7938bcdd1f5efef25ce5af737f0a377a",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
root@ird-6-0:~# docker network inspect my_bridge
[
{
"Name": "my_bridge",
"Id": "ded4841859fd644ec6b926d45d43f7ec02a1f2557908c5855126e769e43b3c52",
"Created": "2017-04-26T13:25:25.76496649Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Containers": {
"90060b15d155bb433bb4ceb3e1df5e0ce366490c892d0237747e43f742b32276": {
"Name": "ubuntu3",
"EndpointID": "5dfb726e3da2a1e4104435117e74cba047d2118eecf064a67ab2040cfbf4bb61",
"MacAddress": "02:42:ac:12:00:02",
"IPv4Address": "172.18.0.2/16",
"IPv6Address": ""
},
"a7db47e51868e16e8bff42a061d1bb29b1d34fa1226a0d01ee9af200e4fafc20": {
"Name": "ubuntu2",
"EndpointID": "7c30b541fde9d0af531b09ce59e64877fa7564a071c119a13647ef14e4fdde5d",
"MacAddress": "02:42:ac:12:00:03",
"IPv4Address": "172.18.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
# Check that you can ping the ubuntu3 and ubuntu4 containers from ubuntu2
root@ird-6-0:~# docker run -it --net=my_bridge --name ubuntu4 ubuntu:14.04
root@579ef85742d9:/# roexec ubutu2 ping ubuntu4
Error response from daemon: No such container: ubutu2
root@ird-6-0:~# docker exec ubuntu2 ping ubuntu4
PING ubuntu4 (172.18.0.4) 56(84) bytes of data.
64 bytes from ubuntu4.my_bridge (172.18.0.4): icmp_seq=1 ttl=64 time=0.403 ms
64 bytes from ubuntu4.my_bridge (172.18.0.4): icmp_seq=2 ttl=64 time=0.112 ms
^Z
[3]+ Stopped docker exec ubuntu2 ping ubuntu4
root@ird-6-0:~# docker network inspect my_bridge
[
{
"Name": "my_bridge",
"Id": "ded4841859fd644ec6b926d45d43f7ec02a1f2557908c5855126e769e43b3c52",
"Created": "2017-04-26T13:25:25.76496649Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Containers": {
"579ef85742d9f7369e0013cb7f19af7a36be97f6ba70b32beb40f5d44d17fd01": {
"Name": "ubuntu4",
"EndpointID": "096bb7ddbe4baeaff730daaa81bd17bf3245302c901ffe81669eaa45b464eb21",
"MacAddress": "02:42:ac:12:00:04",
"IPv4Address": "172.18.0.4/16",
"IPv6Address": ""
},
"90060b15d155bb433bb4ceb3e1df5e0ce366490c892d0237747e43f742b32276": {
"Name": "ubuntu3",
"EndpointID": "5dfb726e3da2a1e4104435117e74cba047d2118eecf064a67ab2040cfbf4bb61",
"MacAddress": "02:42:ac:12:00:02",
"IPv4Address": "172.18.0.2/16",
"IPv6Address": ""
},
"a7db47e51868e16e8bff42a061d1bb29b1d34fa1226a0d01ee9af200e4fafc20": {
"Name": "ubuntu2",
"EndpointID": "7c30b541fde9d0af531b09ce59e64877fa7564a071c119a13647ef14e4fdde5d",
"MacAddress": "02:42:ac:12:00:03",
"IPv4Address": "172.18.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
# Check that you can ping the ubuntu2 and ubuntu4 container from ubuntu3
root@ird-6-0:~# docker exec ubuntu3 ping ubuntu2
PING ubuntu2 (172.18.0.3) 56(84) bytes of data.
64 bytes from ubuntu2.my_bridge (172.18.0.3): icmp_seq=1 ttl=64 time=0.444 ms
64 bytes from ubuntu2.my_bridge (172.18.0.3): icmp_seq=2 ttl=64 time=0.132 ms
64 bytes from ubuntu2.my_bridge (172.18.0.3): icmp_seq=3 ttl=64 time=0.137 ms
64 bytes from ubuntu2.my_bridge (172.18.0.3): icmp_seq=4 ttl=64 time=0.125 ms
^Z
[4]+ Stopped docker exec ubuntu3 ping ubuntu2
root@ird-6-0:~# docker exec ubuntu3 ping ubuntu4
PING ubuntu4 (172.18.0.4) 56(84) bytes of data.
64 bytes from ubuntu4.my_bridge (172.18.0.4): icmp_seq=1 ttl=64 time=0.251 ms
64 bytes from ubuntu4.my_bridge (172.18.0.4): icmp_seq=2 ttl=64 time=0.429 ms
64 bytes from ubuntu4.my_bridge (172.18.0.4): icmp_seq=3 ttl=64 time=0.125 ms
64 bytes from ubuntu4.my_bridge (172.18.0.4): icmp_seq=4 ttl=64 time=0.093 ms
^Z
[5]+ Stopped docker exec ubuntu3 ping ubuntu4
root@ird-6-0:~#
- Uses the
-p
option docker run -p [host port]:[container port]
- To map multiple ports, specify the -p option multiple times
# Map port 8080 on the tomcat container to port 80 on the host
docker run -d -p 80:8080 tomcat
# Map port on the host to port 80 on the nginx container and port 81 on the host to port 8080 on the nginx container
docker run -d -p 80:80 -p 81:8080 nginx
docker port <container name>
root@ird-6-0:~# docker run -d -p 80:80 nginx
bbdb23f8b1279f333881394291578d4406a837b96f448c4ae160f8615c06ab0a
root@ird-6-0:~# docker port bbdb23f8b1279f333881394291578d4406a837b96f448c4ae160f8615c06ab0a
80/tcp -> 0.0.0.0:80
# go to your browser : http://159.203.67.250/:80
sudo service docker [start|stop]
# Stop the Docker daemon which should be running as a service
root@ird-6-0:~# sudo service docker stop
# Run docker version
root@ird-6-0:~# docker version
Client:
Version: 17.04.0-ce
API version: 1.28
Go version: go1.7.5
Git commit: 4845c56
Built: Mon Apr 3 18:07:42 2017
OS/Arch: linux/amd64
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
# tart the daemon again but this time use the docker client and specify the daemon command
# mode debug when service doesn't work
root@ird-6-0:~# sudo dockerd &
[1] 19416
root@ird-6-0:~# INFO[0000] libcontainerd: new containerd process, pid: 19423
WARN[0000] containerd: low RLIMIT_NOFILE changing to max current=1024 max=65536
WARN[0000] containerd: 579ef85742d9f7369e0013cb7f19af7a36be97f6ba70b32beb40f5d44d17fd01:init (pid 11978) does not exist
ERRO[0000] containerd: notify OOM events error="open /proc/11978/cgroup: no such file or directory"
WARN[0000] containerd: 90060b15d155bb433bb4ceb3e1df5e0ce366490c892d0237747e43f742b32276:45439947b7ccbb67aed4a9cc98160c0b7c2996d968cf502684a3c5800c4...
INFO[0002] Loading containers: done.
INFO[0002] Daemon has completed initialization
INFO[0002] Docker daemon commit=4845c56 graphdriver=aufs version=17.04.0-ce
INFO[0003] API listen on /var/run/docker.sock
# Run docker version again and verify that you can see the server version
root@ird-6-0:~# docker version
Client:
Version: 17.04.0-ce
API version: 1.28
Go version: go1.7.5
Git commit: 4845c56
Built: Mon Apr 3 18:07:42 2017
OS/Arch: linux/amd64
Server:
Version: 17.04.0-ce
API version: 1.28 (minimum version 1.12)
Go version: go1.7.5
Git commit: 4845c56
Built: Mon Apr 3 18:07:42 2017
OS/Arch: linux/amd64
Experimental: false
# Find the process ID of Docker and us it to stop the Docker daemon
root@ird-6-0:~# pidof dockerd
19417
root@ird-6-0:~# sudo kill $(pidof dockerd)
INFO[0114] Processing signal 'terminated'
root@ird-6-0:~# INFO[0114] stopping containerd after receiving terminated
[1]+ Done sudo dockerd
# Start the daemon again using the service command
root@ird-6-0:~# service docker start
- Docker daemon upstart configuration file : Located in /etc/default/docker
# Docker Upstart and SysVinit configuration file
#
# THIS FILE DOES NOT APPLY TO SYSTEMD
#
# Please see the documentation for "systemd drop-ins":
# https://docs.docker.com/engine/admin/systemd/
#
# Customize location of Docker binary (especially for development testing).
#DOCKERD="/usr/local/bin/dockerd"
# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"
# This is also a handy place to tweak where Docker's temporary files go.
#export DOCKER_TMPDIR="/mnt/bigdrive/docker-tmp"
- How Docker has been started? All is specified into the file docker.service
# Getting the path of the file docker.service
root@ird-6-0:~# systemctl status docker
● docker.service
Loaded: loaded (/etc/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2017-04-27 07:53:39 UTC; 4min 45s ago
Main PID: 19718 (dockerd)
Tasks: 19
Memory: 21.4M
CPU: 1.945s
CGroup: /system.slice/docker.service
├─19718 /usr/bin/dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/doc
└─19726 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libc
Apr 27 07:53:40 ird-6-0 dockerd[19718]: time="2017-04-27T07:53:40.902256104Z" level=warning msg="Your kernel does not support cgroup rt period"
[2]+ Stopped systemctl status docker
- File docker.service
# file /etc/systemd/system/docker.service
[Service]
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=digitalocean
MountFlags=slave
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
Environment=
[Install]
WantedBy=multi-user.target
~
- Setup daemon logging
# Ex 1.2
# Stop the Docker service or process that is currently running
root@ird-6-0:~# sudo service docker stop
# Start Docker daemon interactively and specify the debug logging level
root@ird-6-0:~# sudo dockerd -D &
[4] 19936
root@ird-6-0:~# DEBU[0000] Listener created for HTTP on unix (/var/run/docker.sock)
INFO[0000] libcontainerd: new containerd process, pid: 19943
WARN[0000] containerd: low RLIMIT_NOFILE changing to max current=1024 max=65536
...
DEBU[0001] Registering DELETE, /networks/{id:.*}
INFO[0001] API listen on /var/run/docker.sock
# Run a few Docker commands and observe the log output
root@ird-6-0:~# docker ps
DEBU[0023] Calling GET /_ping
DEBU[0023] Calling GET /v1.28/containers/json
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@ird-6-0:~# docker ps -a
DEBU[0027] Calling GET /_ping
DEBU[0027] Calling GET /v1.28/containers/json?all=1
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9d4fed96e6a0 tranchant/myimage:1.0 "bash" 18 hours ago Exited (0) 18 hours ago thirsty_hodgkin
bbdb23f8b127 nginx "nginx -g 'daemon ..." 18 hours ago Exited (255) 12 minutes ago 0.0.0.0:80->80/tcp, 443/tcp serene_wing
579ef85742d9 ubuntu:14.04 "/bin/bash" 18 hours ago Exited (255) 12 minutes ago ubuntu4
# Stop the Docker daemon
root@ird-6-0:~# sudo kill $(pidof dockerd)
INFO[0060] Processing signal 'terminated'
DEBU[0060] start clean shutdown of all containers with a 15 seconds timeout...
root@ird-6-0:~# DEBU[0060] Cleaning up old mountid : start.
DEBU[0060] Unix socket /run/docker/libnetwork/2f92f6a7c28b8373021dd19f8f010dbaafc3c1f737307221114dd16f1091cec7.sock doesn't exist. cannot accept client connections
DEBU[0060] Cleaning up old mountid : done.
DEBU[0060] Clean shutdown succeeded
INFO[0060] stopping containerd after receiving terminated
DEBU[0060] libcontainerd: containerd health check returned error: rpc error: code = 9 desc = grpc: the client connection is closing
[4] Done sudo dockerd -D
# Start it again and change the log level to info.
root@ird-6-0:~# sudo dockerd --log-level=info &
[4] 20080
root@ird-6-0:~# INFO[0000] libcontainerd: new containerd process, pid: 20087
WARN[0000] containerd: low RLIMIT_NOFILE changing to max current=1024 max=65536
INFO[0001] [graphdriver] using prior storage driver: aufs
INFO[0001] Graph migration to content-addressability took 0.00 seconds
WARN[0001] Your kernel does not support swap memory limit
WARN[0001] Your kernel does not support cgroup rt period
WARN[0001] Your kernel does not support cgroup rt runtime
INFO[0001] Loading containers: start.
...
root@ird-6-0:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9d4fed96e6a0 tranchant/myimage:1.0 "bash" 18 hours ago Exited (0) 18 hours ago thirsty_hodgkin
bbdb23f8b127 nginx "nginx -g 'daemon ..." 18 hours ago Exited (255) 13 minutes ago 0.0.0.0:80->80/tcp, 443/tcp serene_wing
579ef85742d9 ubuntu:14.04 "/bin/bash" 18 hours ago Exited (255) 13 minutes ago ubuntu4
# check how docker has been started --log info
root@ird-6-0:~# vi /etc/systemd/system/docker.service
[Service]
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=digitalocean --log-level=info
MountFlags=slave
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
Environment=
[Install]
WantedBy=multi-user.target
root@ird-6-0:~# systemctl daemon-reload
root@ird-6-0:~# sudo service docker start
root@ird-6-0:~# journalctl -u docker.service
root@ird-6-0:~# sudo service docker start
# Login to your Docker Hub account on your terminal
root@ird-6-0:~# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username (18092004):
Password:
Login Succeeded
# Pull the latest Ubuntu image
root@ird-6-0:~# docker pull ubuntu:latest
latest: Pulling from library/ubuntu
Digest: sha256:f3a61450ae43896c4332bda5e78b453f4a93179045f20c8181043b26b5e79028
Status: Image is up to date for ubuntu:latest
# check images
root@ird-6-0:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myimage latest 6ad0afd0e636 19 hours ago 259MB
tranchant/myimage 10.1 6ad0afd0e636 19 hours ago 259MB
test 1.0 dc66e7a6ac88 22 hours ago 188MB
18092004/javahelloworld 1.1 a6121ec6a6c4 23 hours ago 584MB
18092004/javahelloworld 1.0 91473d3b8a90 24 hours ago 584MB
tranchant/mynewjava 1.0 91473d3b8a90 24 hours ago 584MB
tranchant/mynewimage 1.0 1cb383192409 25 hours ago 259MB
tranchant/myimage 1.1 2bb7abf1ab43 43 hours ago 259MB
18092004/myimage 1.0 06bf6c7e7ce0 43 hours ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 43 hours ago 259MB
tomcat latest 1f6eab5f63d3 2 days ago 367MB
ubuntu latest f7b3f317ec73 2 days ago 117MB
ubuntu 14.04 302fa07d8117 2 weeks ago 188MB
root@ird-6-0:~# docker tag ubuntu:latest 18092004/trustedubuntu:latest
root@ird-6-0:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myimage latest 6ad0afd0e636 19 hours ago 259MB
tranchant/myimage 10.1 6ad0afd0e636 19 hours ago 259MB
test 1.0 dc66e7a6ac88 22 hours ago 188MB
18092004/javahelloworld 1.1 a6121ec6a6c4 23 hours ago 584MB
18092004/javahelloworld 1.0 91473d3b8a90 24 hours ago 584MB
tranchant/mynewjava 1.0 91473d3b8a90 24 hours ago 584MB
tranchant/mynewimage 1.0 1cb383192409 25 hours ago 259MB
tranchant/myimage 1.1 2bb7abf1ab43 43 hours ago 259MB
18092004/myimage 1.0 06bf6c7e7ce0 43 hours ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 43 hours ago 259MB
18092004/trustedubuntu latest f7b3f317ec73 2 days ago 117MB
ubuntu latest f7b3f317ec73 2 days ago 117MB
ubuntu 14.04 302fa07d8117 2 weeks ago 188MB
centos 7 a8493f5f50ff 2 weeks ago 192MB
nginx latest 5766334bdaa0 2 weeks ago 183MB
busybox latest 00f017a8c2a6 6 weeks ago 1.11MB
java 7 5dc48a6b75af 3 months ago 584MB
trainingteam/nginx latest 7a1b7351fc6b 7 months ago 183MB
# Push the image to Docker Hub
root@ird-6-0:~# docker push 18092004/trustedubuntu:latest
The push refers to a repository [docker.io/18092004/trustedubuntu]
73e5d2de6e3e: Mounted from library/ubuntu
08f405d988e4: Mounted from library/ubuntu
511ddc11cf68: Mounted from library/ubuntu
a1a54d352248: Mounted from library/ubuntu
9d3227c1793b: Mounted from library/ubuntu
latest: digest: sha256:f3a61450ae43896c4332bda5e78b453f4a93179045f20c8181043b26b5e79028 size: 1357
# Login to your Docker Hub account on a browser and check to make sure you can find your new Repository and Tag
# Enable content trust by setting the environment variable
root@ird-6-0:~# export DOCKER_CONTENT_TRUST=1
# Try and run a container using your trustedubuntu image
# This is because the image we are trying to run the container from is not signed.
root@ird-6-0:~# docker run -it 18092004/trustedubuntu:latest
docker: Error: remote trust data does not exist for docker.io/18092004/trustedubuntu: notary.docker.io does not have trust data for docker.io/18092004/trustedubuntu.
See 'docker run --help'.
# retag avec certifcat + push
# Tag your trustedubuntu image again as 1.0
root@ird-6-0:~# docker tag 18092004/trustedubuntu:latest 18092004/trustedubuntu:1.0
root@ird-6-0:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myimage latest 6ad0afd0e636 19 hours ago 259MB
tranchant/myimage 10.1 6ad0afd0e636 19 hours ago 259MB
test 1.0 dc66e7a6ac88 22 hours ago 188MB
18092004/javahelloworld 1.1 a6121ec6a6c4 23 hours ago 584MB
tranchant/mynewjava 1.0 91473d3b8a90 24 hours ago 584MB
18092004/javahelloworld 1.0 91473d3b8a90 24 hours ago 584MB
tranchant/mynewimage 1.0 1cb383192409 25 hours ago 259MB
tranchant/myimage 1.1 2bb7abf1ab43 43 hours ago 259MB
18092004/myimage 1.0 06bf6c7e7ce0 43 hours ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 43 hours ago 259MB
tomcat latest 1f6eab5f63d3 2 days ago 367MB
ubuntu latest f7b3f317ec73 2 days ago 117MB
18092004/trustedubuntu 1.0 f7b3f317ec73 2 days ago 117MB
18092004/trustedubuntu latest f7b3f317ec73 2 days ago 117MB
ubuntu 14.04 302fa07d8117 2 weeks ago 188MB
centos 7 a8493f5f50ff 2 weeks ago 192MB
nginx latest 5766334bdaa0 2 weeks ago 183MB
busybox latest 00f017a8c2a6 6 weeks ago 1.11MB
java 7 5dc48a6b75af 3 months ago 584MB
trainingteam/nginx latest 7a1b7351fc6b 7 months ago 183MB
# Push your new image tag to Docker Hub. You will be prompted for a root key passphrase and repository key passphrase.
root@ird-6-0:~# docker push 18092004/trustedubuntu:1.0
The push refers to a repository [docker.io/18092004/trustedubuntu]
73e5d2de6e3e: Layer already exists
08f405d988e4: Layer already exists
511ddc11cf68: Layer already exists
a1a54d352248: Layer already exists
9d3227c1793b: Layer already exists
1.0: digest: sha256:f3a61450ae43896c4332bda5e78b453f4a93179045f20c8181043b26b5e79028 size: 1357
Signing and pushing trust metadata
You are about to create a new root signing key passphrase. This passphrase
will be used to protect the most sensitive key in your signing system. Please
choose a long, complex passphrase and be careful to keep the password and the
key file itself secure and backed up. It is highly recommended that you use a
password manager to generate the passphrase and keep it safe. There will be no
way to recover this key. You can find the key in your config directory.
Enter passphrase for new root key with ID 6e95bc8:
Repeat passphrase for new root key with ID 6e95bc8:
Enter passphrase for new repository key with ID de2d8d8 (docker.io/18092004/trustedubuntu):
Repeat passphrase for new repository key with ID de2d8d8 (docker.io/18092004/trustedubuntu):
Finished initializing "docker.io/18092004/trustedubuntu"
Successfully signed "docker.io/18092004/trustedubuntu":1.0
# check key
root@ird-6-0:~# cd .docker/trust/private/root_keys/
root@ird-6-0:~/.docker/trust/private/root_keys# ls
6e95bc83a249dd32e0b453e7816cfa7d515ca4d8af3b8da56023a53c8d3040b1.key
root@ird-6-0:~/.docker/trust/private/root_keys# cat 6e95bc83a249dd32e0b453e7816cfa7d515ca4d8af3b8da56023a53c8d3040b1.key
-----BEGIN EC PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,3a43d16cfc999b6a9fc201f30f6c030b
role: root
jdLCzVGMq3isRsbUJk5KhMT6nuJ6GlmndV4mvn4lPKWDS0jA2cFVLG9tUErUdWLN
Av24rJAH/SW5x+inYRrgc4yXUIDxDXt1kJiqJ0KA+11a7ue6LIXeyrnIbAGSqSqh
AoTTqmBrzR3AB3zunlTJJTWxbmYnJ0aohQAw4PL4Eyc=
-----END EC PRIVATE KEY-----
root@ird-6-0:~/.docker/trust/private/root_keys# cd
#check image key
root@ird-6-0:~/.docker/trust/private/tuf_keys/docker.io/18092004/trustedubuntu# readlink -f de2d8d8fab22f079c326d6db512ac7faaadbecdae984573b5436cdb8c3270534.key
/root/.docker/trust/private/tuf_keys/docker.io/18092004/trustedubuntu/de2d8d8fab22f079c326d6db512ac7faaadbecdae984573b5436cdb8c3270534.key
#certificat
root@ird-6-0:~# docker run -it 18092004/trustedubuntu:latest
docker: No trust data for latest.
See 'docker run --help'.
root@ird-6-0:~# docker run -it 18092004/trustedubuntu:1.0
root@70516e4a17b6:/# exit
exit
root@ird-6-0:~# docker run -it ubuntu:latest
root@770d03c14c8d:/# exit
exit
# The same image tag can be signed and unsigned
# Turn off content trust
root@ird-6-0:~# unset DOCKER_CONTENT_TRUST
# Run a container using the trustedubuntu:1.0 image from Exercise 3.2.
# Get terminal access into the container
root@ird-6-0:~# docker run -it 18092004/trustedubuntu:1.0
# Add a file called unsigned.txt and exit
root@62f969ec88d7:/# touch unsigned.txt
root@62f969ec88d7:/# exit
exit
root@ird-6-0:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
62f969ec88d7 18092004/trustedubuntu:1.0 "/bin/bash" 30 seconds ago Exited (0) 19 seconds ago peaceful_lumiere
770d03c14c8d ubuntu "/bin/bash" 4 minutes ago Exited (0) 2 minutes ago friendly_shannon
70516e4a17b6 18092004/trustedubuntu "/bin/bash" 5 minutes ago Exited (0) 5 minutes ago silly_colden
9d4fed96e6a0 tranchant/myimage:1.0 "bash" 19 hours ago Exited (0) 19 hours ago thirsty_hodgkin
bbdb23f8b127 nginx "nginx -g 'daemon ..." 19 hours ago Exited (255) About an hour ago 0.0.0.0:80->80/tcp, 443/tcp serene_wing
579ef85742d9 ubuntu:14.04 "/bin/bash" 19 hours ago Exited (255) About an hour ago ubuntu4
90060b15d155 ubuntu:14.04 "/bin/bash" 20 hours ago Exited (255) About an hour ago ubuntu3
a7db47e51868 ubuntu:14.04 "bash" 20 hours ago Exited (255) About an hour ago ubuntu2
a83bc1d603a1 ubuntu:14.04 "/bin/bash" 20 hours ago Exited (255) About an hour ago ubuntu1
# Commit the container as a new unsigned image with the 1.0 tag.
root@ird-6-0:~# docker commit 62f969ec88d7 18092004/trustedubuntu:1.0
sha256:b24aed948f426798938d8d0b7a1382c93f6f86ed0c70e6205099a2958ee49071
# Push the unsigned image to Docker Hub
root@ird-6-0:~# docker push 18092004/trustedubuntu:1.0
The push refers to a repository [docker.io/18092004/trustedubuntu]
4dee7b676842: Pushed
73e5d2de6e3e: Layer already exists
08f405d988e4: Layer already exists
511ddc11cf68: Layer already exists
a1a54d352248: Layer already exists
9d3227c1793b: Layer already exists
1.0: digest: sha256:6a4bfe4e9b635fe9fdbe41b594cb18d7c0a5ea37fe9a9388f857cf383245908d size: 1564
# Switch over to the Node 1 instance
# Run a container with a bash terminal using the trustedubuntu:1.0 image
root@ird-6-1:~# docker run -it 18092004/trustedubuntu:1.0 bash
Unable to find image '18092004/trustedubuntu:1.0' locally
1.0: Pulling from 18092004/trustedubuntu
aafe6b5e13de: Pull complete
0a2b43a72660: Pull complete
18bdd1e546d2: Pull complete
8198342c3e05: Pull complete
f56970a44fd4: Pull complete
b2979c74c7f5: Pull complete
Digest: sha256:6a4bfe4e9b635fe9fdbe41b594cb18d7c0a5ea37fe9a9388f857cf383245908d
Status: Downloaded newer image for 18092004/trustedubuntu:1.0
root@a37f289af87c:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp unsigned.txt usr var
root@a37f289af87c:/# exit
exit
# Run another container using the same image but this time run it with content trust enabled
root@ird-6-1:~# docker run -it --disable-content-trust=false 18092004/trustedubuntu:1.0 bash
Unable to find image '18092004/trustedubuntu:1.0' locally
sha256:f3a61450ae43896c4332bda5e78b453f4a93179045f20c8181043b26b5e79028: Pulling from 18092004/trustedubuntu
aafe6b5e13de: Already exists
0a2b43a72660: Already exists
18bdd1e546d2: Already exists
8198342c3e05: Already exists
f56970a44fd4: Already exists
Digest: sha256:f3a61450ae43896c4332bda5e78b453f4a93179045f20c8181043b26b5e79028
Status: Downloaded newer image for 18092004/trustedubuntu@sha256:f3a61450ae43896c4332bda5e78b453f4a93179045f20c8181043b26b5e79028
Tagging 18092004/trustedubuntu@sha256:f3a61450ae43896c4332bda5e78b453f4a93179045f20c8181043b26b5e79028 as 18092004/trustedubuntu:1.0
# Notice it is not present because our signed image is currently slightly older than the unsigned image and we did not create that file in it
root@89bd9ce857fe:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
# Cleanup
unset DOCKER_CONTENT_TRUST
#
root@ird-6-0:~# docker run -d -p 5000:5000 registry:2.5
Unable to find image 'registry:2.5' locally
2.5: Pulling from library/registry
b7f33cc0b48e: Pull complete
46730e1e05c9: Pull complete
b7574c100797: Pull complete
2e5b74c7b611: Pull complete
ba42bd458a59: Pull complete
Digest: sha256:946480a23b33480b8e7cdb89b82c1bd6accae91a8e66d017e21e8b56551f6209
Status: Downloaded newer image for registry:2.5
2a5da67f7935186d9d8e56899cb5c2658620d2343b2e1a4ea600bc14f7c8314d
root@ird-6-0:~# curl -i http://localhost:5000/v2/
HTTP/1.1 200 OK
Content-Length: 2
Content-Type: application/json; charset=utf-8
Docker-Distribution-Api-Version: registry/2.0
X-Content-Type-Options: nosniff
Date: Thu, 27 Apr 2017 09:41:47 GMT
{}root@ird-6-0:~#
#EX4.2 – Push images
{}root@ird-6-0:~# docker pull busybox
Using default tag: latest
latest: Pulling from library/busybox
Digest: sha256:32f093055929dbc23dec4d03e09dfe971f5973a9ca5cf059cbfb644c206aa83f
Status: Image is up to date for busybox:latest
root@ird-6-0:~# docker tag busybox localhost:5000/tranchant/mybusybox:1.0
root@ird-6-0:~# docker push localhost:5000/tranchant/mybusybox:1.0
The push refers to a repository [localhost:5000/tranchant/mybusybox]
c0de73ac9968: Pushed
1.0: digest: sha256:68effe31a4ae8312e47f54bec52d1fc925908009ce7e6f734e1b54a4169081c5 size: 527
root@ird-6-0:~# docker tag busybox localhost:5000/tranchant/mybusybox:1.1
root@ird-6-0:~# docker push localhost:5000/tranchant/mybusybox:1.1
The push refers to a repository [localhost:5000/tranchant/mybusybox]
c0de73ac9968: Layer already exists
1.1: digest: sha256:68effe31a4ae8312e47f54bec52d1fc925908009ce7e6f734e1b54a4169081c5 size: 527
#node1 pull
root@ird-6-1:~# curl http://159.203.67.250:5000/v2/tranchant/mybusybox/tags/list
{"name":"tranchant/mybusybox","tags":["1.0","1.1"]}
$
root@ird-6-1:~# docker pull 159.203.67.250:5000/tranchant/mybusybox:1.0
Error response from daemon: Get https://159.203.67.250:5000/v1/_ping: http: server gave HTTP response to HTTPS client
root@ird-6-1:~# docker pull 159.203.67.250:5000/tranchant/mybusybox:1.0
root@ird-6-1:~# docker pull 159.203.67.250:5000/tranchant/mybusybox:1.0
Error response from daemon: Get https://159.203.67.250:5000/v1/_ping: http: server gave HTTP response to HTTPS client
root@ird-6-1:~#
root@ird-6-1:~#
root@ird-6-1:~# vi /etc/systemd/system/docker.service
root@ird-6-1:~# service docker restart
Warning: docker.service changed on disk. Run 'systemctl daemon-reload' to reload units.
root@ird-6-1:~# systemctl daemon-reload
root@ird-6-1:~# service docker restart
root@ird-6-1:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
18092004/trustedubuntu <none> b24aed948f42 About an hour ago 117MB
18092004/trustedubuntu 1.0 f7b3f317ec73 2 days ago 117MB
root@ird-6-1:~# docker pull 159.203.67.250:5000/tranchant/mybusybox:1.0
1.0: Pulling from tranchant/mybusybox
04176c8b224a: Pull complete
Digest: sha256:68effe31a4ae8312e47f54bec52d1fc925908009ce7e6f734e1b54a4169081c5
Status: Downloaded newer image for 159.203.67.250:5000/tranchant/mybusybox:1.0
root@ird-6-1:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
18092004/trustedubuntu <none> b24aed948f42 About an hour ago 117MB
18092004/trustedubuntu 1.0 f7b3f317ec73 2 days ago 117MB
159.203.67.250:5000/tranchant/mybusybox 1.0 00f017a8c2a6 6 weeks ago 1.11MB
<a name="docker-machine>
- Automatise la creation de machines docker
# on node0
#https://github.com/docker/machine/releases
root@ird-6-0:~# curl -L https://github.com/docker/machine/releases/download/v0.11.0/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine &&
> chmod +x /tmp/docker-machine &&
> sudo cp /tmp/docker-machine /usr/local/bin/docker-machine
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 600 0 600 0 0 2188 0 --:--:-- --:--:-- --:--:-- 2197
100 24.4M 100 24.4M 0 0 23.1M 0 0:00:01 0:00:01 --:--:-- 32.7M
root@ird-6-0:~#
# test installation
root@ird-6-0:~# docker-machine
Usage: docker-machine [OPTIONS] COMMAND [arg...]
Create and manage machines running Docker.
Version: 0.11.0, build 5b27455
Author:
Docker Machine Contributors - <https://github.com/docker/machine>
Options:
--debug, -D Enable debug mode
--storage-path, -s "/root/.docker/machine" Configures storage path [$MACHINE_STORAGE_PATH]
--tls-ca-cert CA to verify remotes against [$MACHINE_TLS_CA_CERT]
--tls-ca-key Private key to generate certificates [$MACHINE_TLS_CA_KEY]
--tls-client-cert Client cert to use for TLS [$MACHINE_TLS_CLIENT_CERT]
--tls-client-key Private key used in client TLS auth [$MACHINE_TLS_CLIENT_KEY]
--github-api-token Token to use for requests to the Github API [$MACHINE_GITHUB_API_TOKEN]
--native-ssh Use the native (Go-based) SSH implementation. [$MACHINE_NATIVE_SSH]
--bugsnag-api-token BugSnag API token for crash reporting [$MACHINE_BUGSNAG_API_TOKEN]
--help, -h show help
--version, -v print the version
Commands:
active Print which machine is active
config Print the connection config for machine
create Create a machine
env Display the commands to set up the environment for the Docker client
inspect Inspect information about a machine
ip Get the IP address of a machine
kill Kill a machine
ls List machines
provision Re-provision existing machines
regenerate-certs Regenerate TLS Certificates for a machine
restart Restart a machine
rm Remove a machine
ssh Log into or run a command on a machine with SSH.
scp Copy files between machines
start Start a machine
status Get the status of a machine
stop Stop a machine
upgrade Upgrade a machine to the latest version of Docker
url Get the URL of a machine
version Show the Docker Machine version or a machine docker version
help Shows a list of commands or help for one command
Run 'docker-machine COMMAND --help' for more information on a command.
root@ird-6-0:~#
root@ird-6-0:~# docker-machine create --driver digitalocean --digitalocean-access-token 576aa209c7e0bf04fbdf0085897d42fa432278a8c8a2a5efd70ef5d8ab8e0a4f --digitalocean-size 2gb testhost
Creating CA: /root/.docker/machine/certs/ca.pem
Creating client certificate: /root/.docker/machine/certs/cert.pem
Running pre-create checks...
Creating machine...
(testhost) Creating SSH key...
(testhost) Creating Digital Ocean droplet...
(testhost) Waiting for IP address to be assigned to the Droplet...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with ubuntu(systemd)...
Installing Docker...
- gere certifciat, network etc.
- displays all the host machines that have been provisioned
- Can easily see hosts across different cloud providers
root@ird-6-0:~# docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
testhost - digitalocean Running tcp://45.55.81.249:2376 v17.04.0-ce
root@ird-6-0:~#
root@ird-6-0:~# docker-machine ssh testhost
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-71-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
39 packages can be updated.
18 updates are security updates.
*** System restart required ***
root@testhost:~#
#envt machine hote
root@ird-6-0:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2a5da67f7935 registry:2.5 "/entrypoint.sh /e..." About an hour ago Up About an hour 0.0.0.0:5000->5000/tcp ecstatic_neumann
root@ird-6-0:~# docker-machine testhost
docker-machine: 'testhost' is not a docker-machine command. See 'docker-machine --help'.
root@ird-6-0:~# docker-machine env testhost
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://45.55.81.249:2376"
export DOCKER_CERT_PATH="/root/.docker/machine/machines/testhost"
export DOCKER_MACHINE_NAME="testhost"
# Run this command to configure your shell:
# eval $(docker-machine env testhost)
root@ird-6-0:~# eval $(docker-machine env testhost)
root@ird-6-0:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@ird-6-0:~# docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
testhost * digitalocean Running tcp://45.55.81.249:2376 v17.04.0-ce
root@ird-6-0:~#
root@ird-6-0:~# docker-machine active
testhost
root@ird-6-0:~/.docker/machine/machines# pwd
/root/.docker/machine/machines
root@ird-6-0:~/.docker/machine/machines# ls
testhost
root@ird-6-0:~/.docker/machine/machines#
root@ird-6-0:~/.docker/machine/machines# docker-machine ssh testhost -- ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 10:51 ? 00:00:06 /sbin/init
root 2 0 0 10:51 ? 00:00:00 [kthreadd]
root 3 2 0 10:51 ? 00:00:00 [ksoftirqd/0]
root 5 2 0 10:51 ? 00:00:00 [kworker/0:0H]
root 6 2 0 10:51 ? 00:00:00 [kworker/u4:0]
root 7 2 0 10:51 ? 00:00:00 [rcu_sched]
root 8 2 0 10:51 ? 00:00:00 [rcu_bh]
root 9 2 0 10:51 ? 00:00:00 [migration/0]
root 10 2 0 10:51 ? 00:00:00 [watchdog/0]
root 11 2 0 10:51 ? 00:00:00 [watchdog/1]
root 12 2 0 10:51 ? 00:00:00 [migration/1]
root 13 2 0 10:51 ? 00:00:00 [ksoftirqd/1]
root 14 2 0 10:51 ? 00:00:00 [kworker/1:0]
root 15 2 0 10:51 ? 00:00:00 [kworker/1:0H]
root 16 2 0 10:51 ? 00:00:00 [kdevtmpfs]
root 17 2 0 10:51 ? 00:00:00 [netns]
root 18 2 0 10:51 ? 00:00:00 [perf]
root 19 2 0 10:51 ? 00:00:00 [khungtaskd]
root 20 2 0 10:51 ? 00:00:00 [writeback]
root 21 2 0 10:51 ? 00:00:00 [ksmd]
root 22 2 0 10:51 ? 00:00:00 [khugepaged]
root 23 2 0 10:51 ? 00:00:00 [crypto]
root 24 2 0 10:51 ? 00:00:00 [kintegrityd]
root 25 2 0 10:51 ? 00:00:00 [bioset]
root 26 2 0 10:51 ? 00:00:00 [kblockd]
root 27 2 0 10:51 ? 00:00:00 [ata_sff]
root 28 2 0 10:51 ? 00:00:00 [md]
root 29 2 0 10:51 ? 00:00:00 [devfreq_wq]
root 34 2 0 10:51 ? 00:00:00 [kswapd0]
root 35 2 0 10:51 ? 00:00:00 [vmstat]
root 36 2 0 10:51 ? 00:00:00 [fsnotify_mark]
root 37 2 0 10:51 ? 00:00:00 [ecryptfs-kthrea]
root 53 2 0 10:51 ? 00:00:00 [kthrotld]
root 54 2 0 10:51 ? 00:00:00 [acpi_thermal_pm]
root 55 2 0 10:51 ? 00:00:00 [vballoon]
root 56 2 0 10:51 ? 00:00:00 [bioset]
root 57 2 0 10:51 ? 00:00:00 [bioset]
root 58 2 0 10:51 ? 00:00:00 [bioset]
root 59 2 0 10:51 ? 00:00:00 [bioset]
root 60 2 0 10:51 ? 00:00:00 [bioset]
root 61 2 0 10:51 ? 00:00:00 [bioset]
root 62 2 0 10:51 ? 00:00:00 [bioset]
root 63 2 0 10:51 ? 00:00:00 [bioset]
root 64 2 0 10:51 ? 00:00:00 [bioset]
root 65 2 0 10:51 ? 00:00:00 [scsi_eh_0]
root 66 2 0 10:51 ? 00:00:00 [scsi_tmf_0]
root 67 2 0 10:51 ? 00:00:00 [scsi_eh_1]
root 68 2 0 10:51 ? 00:00:00 [scsi_tmf_1]
root 70 2 0 10:51 ? 00:00:00 [kworker/u4:3]
root 74 2 0 10:51 ? 00:00:00 [ipv6_addrconf]
root 87 2 0 10:51 ? 00:00:00 [deferwq]
root 88 2 0 10:51 ? 00:00:00 [charger_manager]
root 126 2 0 10:51 ? 00:00:00 [scsi_eh_2]
root 127 2 0 10:51 ? 00:00:00 [scsi_tmf_2]
root 128 2 0 10:51 ? 00:00:00 [bioset]
root 130 2 0 10:51 ? 00:00:00 [bioset]
root 131 2 0 10:51 ? 00:00:00 [bioset]
root 132 2 0 10:51 ? 00:00:00 [bioset]
root 133 2 0 10:51 ? 00:00:00 [bioset]
root 134 2 0 10:51 ? 00:00:00 [bioset]
root 135 2 0 10:51 ? 00:00:00 [bioset]
root 136 2 0 10:51 ? 00:00:00 [bioset]
root 138 2 0 10:51 ? 00:00:00 [kpsmoused]
root 488 2 0 10:51 ? 00:00:00 [raid5wq]
root 518 2 0 10:51 ? 00:00:00 [bioset]
root 538 2 0 10:51 ? 00:00:00 [jbd2/vda1-8]
root 539 2 0 10:51 ? 00:00:00 [ext4-rsv-conver]
root 616 2 0 10:51 ? 00:00:00 [iscsi_eh]
root 625 1 0 10:51 ? 00:00:00 /lib/systemd/systemd-journald
root 631 2 0 10:51 ? 00:00:00 [kauditd]
root 632 2 0 10:51 ? 00:00:00 [ib_addr]
root 636 2 0 10:51 ? 00:00:00 [ib_mcast]
root 637 2 0 10:51 ? 00:00:00 [ib_nl_sa_wq]
root 638 2 0 10:51 ? 00:00:00 [ib_cm]
root 639 2 0 10:51 ? 00:00:00 [iw_cm_wq]
root 640 2 0 10:51 ? 00:00:00 [rdma_cm]
root 667 1 0 10:51 ? 00:00:00 /sbin/lvmetad -f
root 682 2 0 10:51 ? 00:00:00 [kworker/0:3]
root 689 1 0 10:51 ? 00:00:00 /lib/systemd/systemd-udevd
systemd+ 763 1 0 10:51 ? 00:00:00 /lib/systemd/systemd-timesyncd
root 769 2 0 10:51 ? 00:00:00 [kworker/1:1H]
root 792 2 0 10:51 ? 00:00:00 [kvm-irqfd-clean]
root 1163 2 0 10:51 ? 00:00:00 [kworker/0:1H]
root 1256 1 0 10:51 ? 00:00:00 /sbin/iscsid
root 1257 1 0 10:51 ? 00:00:00 /sbin/iscsid
message+ 1261 1 0 10:51 ? 00:00:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root 1266 1 0 10:51 ? 00:00:00 /usr/lib/accountsservice/accounts-daemon
root 1268 1 0 10:51 ? 00:00:00 /lib/systemd/systemd-logind
syslog 1270 1 0 10:51 ? 00:00:00 /usr/sbin/rsyslogd -n
root 1276 1 0 10:51 ? 00:00:00 /usr/sbin/acpid
root 1283 1 0 10:51 ? 00:00:00 /usr/lib/snapd/snapd
root 1290 1 0 10:51 ? 00:00:00 /usr/bin/lxcfs /var/lib/lxcfs/
root 1294 1 0 10:51 ? 00:00:00 /usr/sbin/cron -f
daemon 1298 1 0 10:51 ? 00:00:00 /usr/sbin/atd -f
root 1342 1 0 10:51 ? 00:00:00 /sbin/mdadm --monitor --pid-file /run/mdadm/monitor.pid --daemonise --scan --syslog
root 1362 1 0 10:51 ? 00:00:00 /usr/lib/policykit-1/polkitd --no-debug
root 1404 1 0 10:51 ? 00:00:00 /usr/sbin/irqbalance --pid=/var/run/irqbalance.pid
root 1427 1 0 10:51 tty1 00:00:00 /sbin/agetty --noclear tty1 linux
root 1436 1 0 10:51 ttyS0 00:00:00 /sbin/agetty --keep-baud 115200 38400 9600 ttyS0 vt220
root 1631 1 0 10:51 ? 00:00:00 /usr/sbin/sshd -D
root 13683 2 0 10:53 ? 00:00:00 [xfsalloc]
root 13684 2 0 10:53 ? 00:00:00 [xfs_mru_cache]
root 20575 2 0 10:53 ? 00:00:00 [jfsIO]
root 20576 2 0 10:53 ? 00:00:00 [jfsCommit]
root 20577 2 0 10:53 ? 00:00:00 [jfsCommit]
root 20578 2 0 10:53 ? 00:00:00 [jfsSync]
root 30609 1 0 10:54 ? 00:00:01 dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=digitalocean
root 30619 30609 0 10:54 ? 00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
root 30907 2 0 10:59 ? 00:00:00 [kworker/1:1]
root 30909 2 0 10:59 ? 00:00:00 [kworker/0:0]
root 30963 1631 4 11:04 ? 00:00:00 sshd: root@notty
root 30966 2 0 11:04 ? 00:00:00 [kworker/1:2]
root 30968 1 0 11:04 ? 00:00:00 /lib/systemd/systemd --user
root 30970 2 0 11:04 ? 00:00:00 [kworker/0:1]
root 30972 30968 0 11:04 ? 00:00:00 (sd-pam)
root 31004 30963 0 11:04 ? 00:00:00 ps -ef
root@ird-6-0:~/.docker/machine/machines#
root@ird-6-0:~/.docker/machine/machines# pwd
/root/.docker/machine/machines
root@ird-6-0:~/.docker/machine/machines# ls
testhost
root@ird-6-0:~/.docker/machine/machines# docker-machine ssh testhost -- ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 10:51 ? 00:00:06 /sbin/init
root 2 0 0 10:51 ? 00:00:00 [kthreadd]
root 3 2 0 10:51 ? 00:00:00 [ksoftirqd/0]
root 5 2 0 10:51 ? 00:00:00 [kworker/0:0H]
root 6 2 0 10:51 ? 00:00:00 [kworker/u4:0]
root 7 2 0 10:51 ? 00:00:00 [rcu_sched]
root 8 2 0 10:51 ? 00:00:00 [rcu_bh]
root 9 2 0 10:51 ? 00:00:00 [migration/0]
root 10 2 0 10:51 ? 00:00:00 [watchdog/0]
root 11 2 0 10:51 ? 00:00:00 [watchdog/1]
root 12 2 0 10:51 ? 00:00:00 [migration/1]
root 13 2 0 10:51 ? 00:00:00 [ksoftirqd/1]
root 14 2 0 10:51 ? 00:00:00 [kworker/1:0]
root 15 2 0 10:51 ? 00:00:00 [kworker/1:0H]
root 16 2 0 10:51 ? 00:00:00 [kdevtmpfs]
root 17 2 0 10:51 ? 00:00:00 [netns]
root 18 2 0 10:51 ? 00:00:00 [perf]
root 19 2 0 10:51 ? 00:00:00 [khungtaskd]
root 20 2 0 10:51 ? 00:00:00 [writeback]
root 21 2 0 10:51 ? 00:00:00 [ksmd]
root 22 2 0 10:51 ? 00:00:00 [khugepaged]
root 23 2 0 10:51 ? 00:00:00 [crypto]
root 24 2 0 10:51 ? 00:00:00 [kintegrityd]
root 25 2 0 10:51 ? 00:00:00 [bioset]
root 26 2 0 10:51 ? 00:00:00 [kblockd]
root 27 2 0 10:51 ? 00:00:00 [ata_sff]
root 28 2 0 10:51 ? 00:00:00 [md]
root 29 2 0 10:51 ? 00:00:00 [devfreq_wq]
root 34 2 0 10:51 ? 00:00:00 [kswapd0]
root 35 2 0 10:51 ? 00:00:00 [vmstat]
root 36 2 0 10:51 ? 00:00:00 [fsnotify_mark]
root 37 2 0 10:51 ? 00:00:00 [ecryptfs-kthrea]
root 53 2 0 10:51 ? 00:00:00 [kthrotld]
root 54 2 0 10:51 ? 00:00:00 [acpi_thermal_pm]
root 55 2 0 10:51 ? 00:00:00 [vballoon]
root 56 2 0 10:51 ? 00:00:00 [bioset]
root 57 2 0 10:51 ? 00:00:00 [bioset]
root 58 2 0 10:51 ? 00:00:00 [bioset]
root 59 2 0 10:51 ? 00:00:00 [bioset]
root 60 2 0 10:51 ? 00:00:00 [bioset]
root 61 2 0 10:51 ? 00:00:00 [bioset]
root 62 2 0 10:51 ? 00:00:00 [bioset]
root 63 2 0 10:51 ? 00:00:00 [bioset]
root 64 2 0 10:51 ? 00:00:00 [bioset]
root 65 2 0 10:51 ? 00:00:00 [scsi_eh_0]
root 66 2 0 10:51 ? 00:00:00 [scsi_tmf_0]
root 67 2 0 10:51 ? 00:00:00 [scsi_eh_1]
root 68 2 0 10:51 ? 00:00:00 [scsi_tmf_1]
root 70 2 0 10:51 ? 00:00:00 [kworker/u4:3]
root 74 2 0 10:51 ? 00:00:00 [ipv6_addrconf]
root 87 2 0 10:51 ? 00:00:00 [deferwq]
root 88 2 0 10:51 ? 00:00:00 [charger_manager]
root 126 2 0 10:51 ? 00:00:00 [scsi_eh_2]
root 127 2 0 10:51 ? 00:00:00 [scsi_tmf_2]
root 128 2 0 10:51 ? 00:00:00 [bioset]
root 130 2 0 10:51 ? 00:00:00 [bioset]
root 131 2 0 10:51 ? 00:00:00 [bioset]
root 132 2 0 10:51 ? 00:00:00 [bioset]
root 133 2 0 10:51 ? 00:00:00 [bioset]
root 134 2 0 10:51 ? 00:00:00 [bioset]
root 135 2 0 10:51 ? 00:00:00 [bioset]
root 136 2 0 10:51 ? 00:00:00 [bioset]
root 138 2 0 10:51 ? 00:00:00 [kpsmoused]
root 488 2 0 10:51 ? 00:00:00 [raid5wq]
root 518 2 0 10:51 ? 00:00:00 [bioset]
root 538 2 0 10:51 ? 00:00:00 [jbd2/vda1-8]
root 539 2 0 10:51 ? 00:00:00 [ext4-rsv-conver]
root 616 2 0 10:51 ? 00:00:00 [iscsi_eh]
root 625 1 0 10:51 ? 00:00:00 /lib/systemd/systemd-journald
root 631 2 0 10:51 ? 00:00:00 [kauditd]
root 632 2 0 10:51 ? 00:00:00 [ib_addr]
root 636 2 0 10:51 ? 00:00:00 [ib_mcast]
root 637 2 0 10:51 ? 00:00:00 [ib_nl_sa_wq]
root 638 2 0 10:51 ? 00:00:00 [ib_cm]
root 639 2 0 10:51 ? 00:00:00 [iw_cm_wq]
root 640 2 0 10:51 ? 00:00:00 [rdma_cm]
root 667 1 0 10:51 ? 00:00:00 /sbin/lvmetad -f
root 682 2 0 10:51 ? 00:00:00 [kworker/0:3]
root 689 1 0 10:51 ? 00:00:00 /lib/systemd/systemd-udevd
systemd+ 763 1 0 10:51 ? 00:00:00 /lib/systemd/systemd-timesyncd
root 769 2 0 10:51 ? 00:00:00 [kworker/1:1H]
root 792 2 0 10:51 ? 00:00:00 [kvm-irqfd-clean]
root 1163 2 0 10:51 ? 00:00:00 [kworker/0:1H]
root 1256 1 0 10:51 ? 00:00:00 /sbin/iscsid
root 1257 1 0 10:51 ? 00:00:00 /sbin/iscsid
message+ 1261 1 0 10:51 ? 00:00:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root 1266 1 0 10:51 ? 00:00:00 /usr/lib/accountsservice/accounts-daemon
root 1268 1 0 10:51 ? 00:00:00 /lib/systemd/systemd-logind
syslog 1270 1 0 10:51 ? 00:00:00 /usr/sbin/rsyslogd -n
root 1276 1 0 10:51 ? 00:00:00 /usr/sbin/acpid
root 1283 1 0 10:51 ? 00:00:00 /usr/lib/snapd/snapd
root 1290 1 0 10:51 ? 00:00:00 /usr/bin/lxcfs /var/lib/lxcfs/
root 1294 1 0 10:51 ? 00:00:00 /usr/sbin/cron -f
daemon 1298 1 0 10:51 ? 00:00:00 /usr/sbin/atd -f
root 1342 1 0 10:51 ? 00:00:00 /sbin/mdadm --monitor --pid-file /run/mdadm/monitor.pid --daemonise --scan --syslog
root 1362 1 0 10:51 ? 00:00:00 /usr/lib/policykit-1/polkitd --no-debug
root 1404 1 0 10:51 ? 00:00:00 /usr/sbin/irqbalance --pid=/var/run/irqbalance.pid
root 1427 1 0 10:51 tty1 00:00:00 /sbin/agetty --noclear tty1 linux
root 1436 1 0 10:51 ttyS0 00:00:00 /sbin/agetty --keep-baud 115200 38400 9600 ttyS0 vt220
root 1631 1 0 10:51 ? 00:00:00 /usr/sbin/sshd -D
root 13683 2 0 10:53 ? 00:00:00 [xfsalloc]
root 13684 2 0 10:53 ? 00:00:00 [xfs_mru_cache]
root 20575 2 0 10:53 ? 00:00:00 [jfsIO]
root 20576 2 0 10:53 ? 00:00:00 [jfsCommit]
root 20577 2 0 10:53 ? 00:00:00 [jfsCommit]
root 20578 2 0 10:53 ? 00:00:00 [jfsSync]
root 30609 1 0 10:54 ? 00:00:01 dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=digitalocean
root 30619 30609 0 10:54 ? 00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
root 30907 2 0 10:59 ? 00:00:00 [kworker/1:1]
root 30909 2 0 10:59 ? 00:00:00 [kworker/0:0]
root 30963 1631 4 11:04 ? 00:00:00 sshd: root@notty
root 30966 2 0 11:04 ? 00:00:00 [kworker/1:2]
root 30968 1 0 11:04 ? 00:00:00 /lib/systemd/systemd --user
root 30970 2 0 11:04 ? 00:00:00 [kworker/0:1]
root 30972 30968 0 11:04 ? 00:00:00 (sd-pam)
root 31004 30963 0 11:04 ? 00:00:00 ps -ef
root@ird-6-0:~/.docker/machine/machines# docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
testhost * digitalocean Running tcp://45.55.81.249:2376 v17.04.0-ce
root@ird-6-0:~/.docker/machine/machines# docker-machine start testhost/
Starting "testhost/"...
Machine "testhost/" is already running.
root@ird-6-0:~/.docker/machine/machines# docker-machine stop testhost/
Stopping "testhost/"...
Machine "testhost/" was stopped.
root@ird-6-0:~/.docker/machine/machines# docker-machine start testhost
Starting "testhost"...
Machine "testhost" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
root@ird-6-0:~/.docker/machine/machines# docker-machine inspect testhost
{
"ConfigVersion": 3,
"Driver": {
"IPAddress": "45.55.81.249",
"MachineName": "testhost",
"SSHUser": "root",
"SSHPort": 22,
"SSHKeyPath": "/root/.docker/machine/machines/testhost/id_rsa",
"StorePath": "/root/.docker/machine",
"SwarmMaster": false,
"SwarmHost": "tcp://0.0.0.0:3376",
"SwarmDiscovery": "",
"AccessToken": "576aa209c7e0bf04fbdf0085897d42fa432278a8c8a2a5efd70ef5d8ab8e0a4f",
"DropletID": 47090013,
"DropletName": "",
"Image": "ubuntu-16-04-x64",
"Region": "nyc3",
"SSHKeyID": 8547148,
"SSHKeyFingerprint": "",
"SSHKey": "",
"Size": "2gb",
"IPv6": false,
"Backups": false,
"PrivateNetworking": false,
"UserDataFile": "",
"Tags": ""
},
"DriverName": "digitalocean",
"HostOptions": {
"Driver": "",
"Memory": 0,
"Disk": 0,
"EngineOptions": {
"ArbitraryFlags": [],
"Dns": null,
"GraphDir": "",
"Env": [],
"Ipv6": false,
"InsecureRegistry": [],
"Labels": [],
"LogLevel": "",
"StorageDriver": "",
"SelinuxEnabled": false,
"TlsVerify": true,
"RegistryMirror": [],
"InstallURL": "https://get.docker.com"
},
"SwarmOptions": {
"IsSwarm": false,
"Address": "",
"Discovery": "",
"Agent": false,
"Master": false,
"Host": "tcp://0.0.0.0:3376",
"Image": "swarm:latest",
"Strategy": "spread",
"Heartbeat": 0,
"Overcommit": 0,
"ArbitraryFlags": [],
"ArbitraryJoinFlags": [],
"Env": null,
"IsExperimental": false
},
"AuthOptions": {
"CertDir": "/root/.docker/machine/certs",
"CaCertPath": "/root/.docker/machine/certs/ca.pem",
"CaPrivateKeyPath": "/root/.docker/machine/certs/ca-key.pem",
"CaCertRemotePath": "",
"ServerCertPath": "/root/.docker/machine/machines/testhost/server.pem",
"ServerKeyPath": "/root/.docker/machine/machines/testhost/server-key.pem",
"ClientKeyPath": "/root/.docker/machine/certs/key.pem",
"ServerCertRemotePath": "",
"ServerKeyRemotePath": "",
"ClientCertPath": "/root/.docker/machine/certs/cert.pem",
"ServerCertSANs": [],
"StorePath": "/root/.docker/machine/machines/testhost"
}
},
"Name": "testhost"
}
root@ird-6-0:~/.docker/machine/machines# docker-machine rm testhost
About to remove testhost
WARNING: This action will delete both local reference and remote instance.
Are you sure? (y/n): y
Successfully removed testhost
root@ird-6-0:~/.docker/machine/machines#
# Install en local pour tester avant de faire le container composé du container redis (bd) + container appli (nodejc)
sudo apt-get install nodejs
sudo apt-get install npm
root@ird-6-0:~# git clone https://github.com/johnny-tu/inventory-service.git
Cloning into 'inventory-service'...
remote: Counting objects: 16, done.
remote: Total 16 (delta 0), reused 0 (delta 0), pack-reused 16
Unpacking objects: 100% (16/16), done.
Checking connectivity... done.
root@ird-6-0:~# cd inventory-service/
root@ird-6-0:~/inventory-service# ls
Dockerfile inventoryService.js
#install client redis utilisé par l appli java pour se connecter à la bd redis
root@ird-6-0:~/inventory-service# npm install redis
/root/inventory-service
└─┬ redis@2.7.1
├── double-ended-queue@2.1.0-0
├── redis-commands@1.3.1
└── redis-parser@2.6.0
npm WARN enoent ENOENT: no such file or directory, open '/root/inventory-service/package.json'
npm WARN inventory-service No description
npm WARN inventory-service No repository field.
npm WARN inventory-service No README data
npm WARN inventory-service No license field.
root@ird-6-0:~/inventory-service#
# lance container bd redis
root@ird-6-0:~/inventory-service# docker run -d -p 6379:6379 --name redisdb redis
Unable to find image 'redis:latest' locally
latest: Pulling from library/redis
cd0a524342ef: Already exists
2832b8d33a94: Pull complete
11ba129f304a: Pull complete
fa9bf5ac8bc6: Pull complete
6b5348ede0fa: Pull complete
e367ab303b30: Pull complete
9fe8eaef9981: Pull complete
Digest: sha256:079a8abb332d42953d72040baeb7beae1585b2ca08502e154fc761d5b1a32ade
Status: Downloaded newer image for redis:latest
0d8639c6e9dc9f594e7d61718de0ca381e1454289672f3010fbd5a2c9eb2cf43
root@ird-6-0:~/inventory-service# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0d8639c6e9dc redis "docker-entrypoint..." 4 minutes ago Up 4 minutes 0.0.0.0:6379->6379/tcp redisdb
2a5da67f7935 registry:2.5 "/entrypoint.sh /e..." 3 hours ago Up 3 hours 0.0.0.0:5000->5000/tcp ecstatic_neumann
# lance appli java qui appelle le container bd et interroge la bd à distabnce
root@ird-6-0:~/inventory-service# nodejs inventoryService.js
connected
Reply: OK
books_count = 123
# notre appli fonctionne, on va la dockerizer du coup en utilisant le Docker file suivant
#Dockerfile
FROM node:slim
COPY inventoryService.js /src/
WORKDIR /src
RUN npm install redis
CMD ["nodejs", "inventoryService.js"]
root@ird-6-0:~/inventory-service# docker build -t inventory-service .
Sending build context to Docker daemon 388.6kB
Step 1/5 : FROM node:slim
slim: Pulling from library/node
cd0a524342ef: Already exists
e39c3ffe4133: Already exists
f444da5fa2cd: Pull complete
69ee8980874a: Pull complete
d5c8431f000e: Pull complete
e4b75d719b75: Pull complete
Digest: sha256:027768a2d778d5b1a2ac393307d643faac8e7c4faf3d511e9a9c31854df17052
Status: Downloaded newer image for node:slim
---> 754e0c30495a
Step 2/5 : COPY inventoryService.js /src/
---> 69fbb510a2cb
Removing intermediate container e50b7b6fd25b
Step 3/5 : WORKDIR /src
---> 4032f8536a31
Removing intermediate container 734c64ebc530
Step 4/5 : RUN npm install redis
---> Running in 1a2ffe556b6b
npm info it worked if it ends with ok
npm info using npm@4.2.0
npm info using node@v7.9.0
npm info attempt registry request try #1 at 12:35:24 PM
npm http request GET https://registry.npmjs.org/redis
npm http 200 https://registry.npmjs.org/redis
npm info addNameTag [ 'redis', 'latest' ]
npm info retry fetch attempt 1 at 12:35:24 PM
npm info attempt registry request try #1 at 12:35:24 PM
npm http fetch GET https://registry.npmjs.org/redis/-/redis-2.7.1.tgz
npm http fetch 200 https://registry.npmjs.org/redis/-/redis-2.7.1.tgz
npm info attempt registry request try #1 at 12:35:24 PM
npm http request GET https://registry.npmjs.org/double-ended-queue
npm info attempt registry request try #1 at 12:35:24 PM
npm http request GET https://registry.npmjs.org/redis-commands
npm info attempt registry request try #1 at 12:35:24 PM
npm http request GET https://registry.npmjs.org/redis-parser
npm http 200 https://registry.npmjs.org/double-ended-queue
npm http 200 https://registry.npmjs.org/redis-commands
npm http 200 https://registry.npmjs.org/redis-parser
npm info addNameTag [ 'double-ended-queue', 'latest' ]
npm info retry fetch attempt 1 at 12:35:24 PM
npm info attempt registry request try #1 at 12:35:24 PM
npm http fetch GET https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz
npm http fetch 200 https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz
npm info addNameTag [ 'redis-commands', 'latest' ]
npm info retry fetch attempt 1 at 12:35:25 PM
npm info attempt registry request try #1 at 12:35:25 PM
npm http fetch GET https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.1.tgz
npm info addNameTag [ 'redis-parser', 'latest' ]
npm http fetch 200 https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.1.tgz
npm info retry fetch attempt 1 at 12:35:25 PM
npm info attempt registry request try #1 at 12:35:25 PM
npm http fetch GET https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz
npm http fetch 200 https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz
npm info lifecycle double-ended-queue@2.1.0-0~preinstall: double-ended-queue@2.1.0-0
npm info lifecycle redis-commands@1.3.1~preinstall: redis-commands@1.3.1
npm info lifecycle redis-parser@2.6.0~preinstall: redis-parser@2.6.0
npm info lifecycle redis@2.7.1~preinstall: redis@2.7.1
npm info linkStuff double-ended-queue@2.1.0-0
npm info linkStuff redis-commands@1.3.1
npm info linkStuff redis-parser@2.6.0
npm info linkStuff redis@2.7.1
npm info lifecycle double-ended-queue@2.1.0-0~install: double-ended-queue@2.1.0-0
npm info lifecycle redis-commands@1.3.1~install: redis-commands@1.3.1
npm info lifecycle redis-parser@2.6.0~install: redis-parser@2.6.0
npm info lifecycle redis@2.7.1~install: redis@2.7.1
npm info lifecycle double-ended-queue@2.1.0-0~postinstall: double-ended-queue@2.1.0-0
npm info lifecycle redis-commands@1.3.1~postinstall: redis-commands@1.3.1
npm info lifecycle redis-parser@2.6.0~postinstall: redis-parser@2.6.0
npm info lifecycle redis@2.7.1~postinstall: redis@2.7.1
/src
`-- redis@2.7.1
+-- double-ended-queue@2.1.0-0
+-- redis-commands@1.3.1
`-- redis-parser@2.6.0
npm WARN enoent ENOENT: no such file or directory, open '/src/package.json'
npm WARN src No description
npm WARN src No repository field.
npm WARN src No README data
npm WARN src No license field.
npm info ok
---> e39eeeeeea37
Removing intermediate container 1a2ffe556b6b
Step 5/5 : CMD nodejs inventoryService.js
---> Running in 33bd215e17cd
---> 2a7697959ab6
Removing intermediate container 33bd215e17cd
Successfully built 2a7697959ab6
root@ird-6-0:~/inventory-service#
# cree un reseau pour les 2 container
root@ird-6-0:~/inventory-service# docker network create nodeapp
b7005d130b33bd3ce29979c408cb02155f1c178e7a64fca95f9eb5bc965d46ea
root@ird-6-0:~/inventory-service# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0d8639c6e9dc redis "docker-entrypoint..." 14 minutes ago Up 14 minutes 0.0.0.0:6379->6379/tcp redisdb
2a5da67f7935 registry:2.5 "/entrypoint.sh /e..." 3 hours ago Up 3 hours 0.0.0.0:5000->5000/tcp ecstatic_neumann
root@ird-6-0:~/inventory-service# docker rm -f redis
Error response from daemon: No such container: redis
root@ird-6-0:~/inventory-service# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0d8639c6e9dc redis "docker-entrypoint..." 15 minutes ago Up 15 minutes 0.0.0.0:6379->6379/tcp redisdb
2a5da67f7935 registry:2.5 "/entrypoint.sh /e..." 3 hours ago Up 3 hours 0.0.0.0:5000->5000/tcp ecstatic_neumann
root@ird-6-0:~/inventory-service# docker rm -f redisdb
redisdb
root@ird-6-0:~/inventory-service# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2a5da67f7935 registry:2.5 "/entrypoint.sh /e..." 3 hours ago Up 3 hours 0.0.0.0:5000->5000/tcp ecstatic_neumann
root@ird-6-0:~/inventory-service# docker run --net nodeapp inventory-service
events.js:163
throw er; // Unhandled 'error' event
^
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at Object.exports._errnoException (util.js:1050:11)
at exports._exceptionWithHostPort (util.js:1073:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)
root@ird-6-0:~/inventory-service# ls
Dockerfile inventoryService.js node_modules
root@ird-6-0:~/inventory-service# vi inventoryService.js
root@ird-6-0:~/inventory-service# docker build -t inventory-service .
Sending build context to Docker daemon 388.6kB
Step 1/5 : FROM node:slim
---> 754e0c30495a
Step 2/5 : COPY inventoryService.js /src/
---> a71fcccccc84
Removing intermediate container f299dc3dfad6
Step 3/5 : WORKDIR /src
---> 89f53c588248
Removing intermediate container 5123d9a37a58
Step 4/5 : RUN npm install redis
---> Running in 6978f1cb1fe8
npm info it worked if it ends with ok
npm info using npm@4.2.0
npm info using node@v7.9.0
npm info attempt registry request try #1 at 12:44:48 PM
npm http request GET https://registry.npmjs.org/redis
npm http 200 https://registry.npmjs.org/redis
npm info addNameTag [ 'redis', 'latest' ]
npm info retry fetch attempt 1 at 12:44:49 PM
npm info attempt registry request try #1 at 12:44:49 PM
npm http fetch GET https://registry.npmjs.org/redis/-/redis-2.7.1.tgz
npm http fetch 200 https://registry.npmjs.org/redis/-/redis-2.7.1.tgz
npm info attempt registry request try #1 at 12:44:49 PM
npm http request GET https://registry.npmjs.org/double-ended-queue
npm info attempt registry request try #1 at 12:44:49 PM
npm http request GET https://registry.npmjs.org/redis-commands
npm info attempt registry request try #1 at 12:44:49 PM
npm http request GET https://registry.npmjs.org/redis-parser
npm http 200 https://registry.npmjs.org/double-ended-queue
npm info addNameTag [ 'double-ended-queue', 'latest' ]
npm info retry fetch attempt 1 at 12:44:49 PM
npm info attempt registry request try #1 at 12:44:49 PM
npm http fetch GET https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz
npm http fetch 200 https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz
npm http 200 https://registry.npmjs.org/redis-commands
npm http 200 https://registry.npmjs.org/redis-parser
npm info addNameTag [ 'redis-commands', 'latest' ]
npm info addNameTag [ 'redis-parser', 'latest' ]
npm info retry fetch attempt 1 at 12:44:49 PM
npm info attempt registry request try #1 at 12:44:49 PM
npm http fetch GET https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.1.tgz
npm info retry fetch attempt 1 at 12:44:49 PM
npm info attempt registry request try #1 at 12:44:49 PM
npm http fetch GET https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz
npm http fetch 200 https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.1.tgz
npm http fetch 200 https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz
npm info lifecycle double-ended-queue@2.1.0-0~preinstall: double-ended-queue@2.1.0-0
npm info lifecycle redis-commands@1.3.1~preinstall: redis-commands@1.3.1
npm info lifecycle redis-parser@2.6.0~preinstall: redis-parser@2.6.0
npm info lifecycle redis@2.7.1~preinstall: redis@2.7.1
npm info linkStuff double-ended-queue@2.1.0-0
npm info linkStuff redis-commands@1.3.1
npm info linkStuff redis-parser@2.6.0
npm info linkStuff redis@2.7.1
npm info lifecycle double-ended-queue@2.1.0-0~install: double-ended-queue@2.1.0-0
npm info lifecycle redis-commands@1.3.1~install: redis-commands@1.3.1
npm info lifecycle redis-parser@2.6.0~install: redis-parser@2.6.0
npm info lifecycle redis@2.7.1~install: redis@2.7.1
npm info lifecycle double-ended-queue@2.1.0-0~postinstall: double-ended-queue@2.1.0-0
npm info lifecycle redis-commands@1.3.1~postinstall: redis-commands@1.3.1
npm info lifecycle redis-parser@2.6.0~postinstall: redis-parser@2.6.0
npm info lifecycle redis@2.7.1~postinstall: redis@2.7.1
/src
`-- redis@2.7.1
+-- double-ended-queue@2.1.0-0
+-- redis-commands@1.3.1
`-- redis-parser@2.6.0
npm WARN enoent ENOENT: no such file or directory, open '/src/package.json'
npm WARN src No description
npm WARN src No repository field.
npm WARN src No README data
npm WARN src No license field.
npm info ok
---> d11dcca10257
Removing intermediate container 6978f1cb1fe8
Step 5/5 : CMD nodejs inventoryService.js
---> Running in 86cb515837e3
---> 815296d633c1
Removing intermediate container 86cb515837e3
Successfully built 815296d633c1
root@ird-6-0:~/inventory-service#
root@ird-6-0:~/inventory-service# docker run --net nodeapp inventory-service
events.js:163
throw er; // Unhandled 'error' event
^
Error: Redis connection to redisdb:6379 failed - getaddrinfo ENOTFOUND redisdb redisdb:6379
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:73:26)
root@ird-6-0:~/inventory-service# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2a5da67f7935 registry:2.5 "/entrypoint.sh /e..." 3 hours ago Up 3 hours 0.0.0.0:5000->5000/tcp ecstatic_neumann
root@ird-6-0:~/inventory-service# docker run -d -p 6379:6379 --name redisdb redis
5f718505587a94552f5552e4b2bf6b1e28fb08e6c915835151e3c9b132de3140
root@ird-6-0:~/inventory-service# docker rm -f redisdb
redisdb
root@ird-6-0:~/inventory-service# docker run -d -p 6379:6379 --name redisdb redis --net nodeapp
db950260df03327503083cbda0f52b25b3cb7d1de3e3b239b4c2f87fb41bc043
root@ird-6-0:~/inventory-service# docker run --net nodeapp inventory-service
events.js:163
throw er; // Unhandled 'error' event
^
Error: Redis connection to redisdb:6379 failed - getaddrinfo ENOTFOUND redisdb redisdb:6379
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:73:26)
root@ird-6-0:~/inventory-service# vi
Dockerfile .git/ inventoryService.js node_modules/
root@ird-6-0:~/inventory-service# vi inventoryService.js
root@ird-6-0:~/inventory-service# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2a5da67f7935 registry:2.5 "/entrypoint.sh /e..." 3 hours ago Up 3 hours 0.0.0.0:5000->5000/tcp ecstatic_neumann
root@ird-6-0:~/inventory-service# docker container prune
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
e2d30c6d8dfc1857f64eb111907fed1d6e4fe624e543647504c0b212594a0a0b
db950260df03327503083cbda0f52b25b3cb7d1de3e3b239b4c2f87fb41bc043
08c0683ec672ac3fa5fd3d052affb04ace6ef75bbb2b786d373295339cb1340b
8c25b55ac49b17666bf3294ec681a031f25496223873e11590308cc7bee52441
62f969ec88d7d93d35c49e796eed185be09f732c7f59bb263a25337d0f743952
770d03c14c8d7247b7dd20fa8387130fd8a56c2ac9c3263ed2cc4459fd3f0018
70516e4a17b6d27e867fd2c98976dd523ad2be30ee62305e6910262429db2a15
9d4fed96e6a06c77e6b29f8dfb0a6a36a69c146414820b6af980fc2b58a59d0f
bbdb23f8b1279f333881394291578d4406a837b96f448c4ae160f8615c06ab0a
579ef85742d9f7369e0013cb7f19af7a36be97f6ba70b32beb40f5d44d17fd01
90060b15d155bb433bb4ceb3e1df5e0ce366490c892d0237747e43f742b32276
a7db47e51868e16e8bff42a061d1bb29b1d34fa1226a0d01ee9af200e4fafc20
a83bc1d603a15931d042594ba77deb68829beddb17d32473ca5c4f1838035220
Total reclaimed space: 65B
root@ird-6-0:~/inventory-service# docker run -d -p 6379:6379 --net nodeapp --name redisdb redis
a9193bad16237d34108f8b39b60114670c455967590bd028e2efaab2213b1d3e
root@ird-6-0:~/inventory-service# docker run --net nodeapp inventory-service
connected
Reply: OK
books_count = 123
# installation docker-compose https://github.com/docker/compose/releases
curl -L https://github.com/docker/compose/releases/download/1.13.0-rc1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# test installation
root@ird-6-0:~# docker-compose
Define and run multi-container applications with Docker.
Usage:
docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...]
docker-compose -h|--help
Options:
-f, --file FILE Specify an alternate compose file (default: docker-compose.yml)
-p, --project-name NAME Specify an alternate project name (default: directory name)
--verbose Show more output
-v, --version Print version and exit
-H, --host HOST Daemon socket to connect to
--tls Use TLS; implied by --tlsverify
--tlscacert CA_PATH Trust certs signed only by this CA
--tlscert CLIENT_CERT_PATH Path to TLS certificate file
--tlskey TLS_KEY_PATH Path to TLS key file
--tlsverify Use TLS and verify the remote
--skip-hostname-check Don't check the daemon's hostname against the name specified
in the client certificate (for example if your docker host
is an IP address)
--project-directory PATH Specify an alternate working directory
(default: the path of the compose file)
Commands:
build Build or rebuild services
bundle Generate a Docker bundle from the Compose file
config Validate and view the compose file
create Create services
down Stop and remove containers, networks, images, and volumes
events Receive real time events from containers
exec Execute a command in a running container
help Get help on a command
images List images
kill Kill containers
logs View output from containers
pause Pause services
port Print the public port for a port binding
ps List containers
pull Pull service images
push Push service images
restart Restart services
rm Remove stopped containers
run Run a one-off command
scale Set number of containers for a service
start Start services
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker-Compose version information
root@ird-6-0:~#
# dockercoins
root@ird-6-0:~# git clone \ https://github.com/docker-training/orchestration-workshop
Cloning into 'orchestration-workshop'...
fatal: I don't handle protocol ' https'
root@ird-6-0:~# git clone https://github.com/docker-training/orchestration-workshop
Cloning into 'orchestration-workshop'...
remote: Counting objects: 1746, done.
remote: Total 1746 (delta 0), reused 0 (delta 0), pack-reused 1746
Receiving objects: 100% (1746/1746), 8.57 MiB | 0 bytes/s, done.
Resolving deltas: 100% (985/985), done.
Checking connectivity... done.
root@ird-6-0:~# cd orchestration-workshop/dockercoins/
root@ird-6-0:~/orchestration-workshop/dockercoins# vi docker-compose.yml
root@ird-6-0:~/orchestration-workshop/dockercoins# vi docker-compose.yml
root@ird-6-0:~/orchestration-workshop/dockercoins# ls
docker-compose.yml docker-compose.yml-images docker-compose.yml-logging hasher rng webui worker
root@ird-6-0:~/orchestration-workshop/dockercoins# ls webui/
Dockerfile files webui.js
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose up
Creating network "dockercoins_default" with the default driver
Building worker
Step 1/5 : FROM python:alpine
alpine: Pulling from library/python
709515475419: Pull complete
7f8ede2d2484: Pull complete
bb42fdb18f87: Pull complete
2fd3ea69d47d: Pull complete
Digest: sha256:e07365eb9209e8f1820dbb634e5ad822d0072e8216065baf8b6e1b5763a46c6a
Status: Downloaded newer image for python:alpine
---> 02dcd3de5240
Step 2/5 : RUN pip install redis
---> Running in 7a542fa92ad1
Collecting redis
Downloading redis-2.10.5-py2.py3-none-any.whl (60kB)
Installing collected packages: redis
Successfully installed redis-2.10.5
---> da689afe436c
Removing intermediate container 7a542fa92ad1
Step 3/5 : RUN pip install requests
---> Running in 155f1ce2afd6
Collecting requests
Downloading requests-2.13.0-py2.py3-none-any.whl (584kB)
Installing collected packages: requests
Successfully installed requests-2.13.0
---> 94c00bd8c635
Removing intermediate container 155f1ce2afd6
Step 4/5 : COPY worker.py /
---> 33a46fb644ee
Removing intermediate container 4efda7326911
Step 5/5 : CMD python worker.py
---> Running in 9bca242b5f6a
---> 8f659dafe3dd
Removing intermediate container 9bca242b5f6a
Successfully built 8f659dafe3dd
WARNING: Image for service worker was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Building hasher
Step 1/7 : FROM ruby:alpine
alpine: Pulling from library/ruby
709515475419: Already exists
7fb3cefb04d0: Pull complete
90b9c8a10de7: Pull complete
6b7eca1d4c36: Pull complete
34fa769a4a3d: Pull complete
Digest: sha256:a4b2dbffabfafdbf6aac2bed261c64b3fc242bf4ea3f3c7930bc141394b04425
Status: Downloaded newer image for ruby:alpine
---> 5eadd5d1419a
Step 2/7 : RUN apk add --update build-base
---> Running in b25c81c67875
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
(1/17) Installing binutils-libs (2.26-r1)
(2/17) Installing binutils (2.26-r1)
(3/17) Installing gmp (6.1.0-r0)
(4/17) Installing isl (0.14.1-r0)
(5/17) Installing libgomp (5.3.0-r0)
(6/17) Installing libatomic (5.3.0-r0)
(7/17) Installing libgcc (5.3.0-r0)
(8/17) Installing mpfr3 (3.1.2-r0)
(9/17) Installing mpc1 (1.0.3-r0)
(10/17) Installing libstdc++ (5.3.0-r0)
(11/17) Installing gcc (5.3.0-r0)
(12/17) Installing make (4.1-r1)
(13/17) Installing musl-dev (1.1.14-r14)
(14/17) Installing libc-dev (0.7-r0)
(15/17) Installing fortify-headers (0.8-r0)
(16/17) Installing g++ (5.3.0-r0)
(17/17) Installing build-base (0.4-r1)
Executing busybox-1.24.2-r13.trigger
OK: 173 MiB in 46 packages
---> 9be58770e7bc
Removing intermediate container b25c81c67875
Step 3/7 : RUN gem install sinatra
---> Running in fcb55b10210a
Successfully installed rack-1.6.5
Successfully installed tilt-2.0.7
Successfully installed rack-protection-1.5.3
Successfully installed sinatra-1.4.8
4 gems installed
---> 43122e414a51
Removing intermediate container fcb55b10210a
Step 4/7 : RUN gem install thin
---> Running in 8a3fa1c13718
Building native extensions. This could take a while...
Successfully installed eventmachine-1.2.3
Successfully installed daemons-1.2.4
Building native extensions. This could take a while...
Successfully installed thin-1.7.0
3 gems installed
---> 483895eeabc2
Removing intermediate container 8a3fa1c13718
Step 5/7 : ADD hasher.rb /
---> b136b624da2a
Removing intermediate container 0a2b2da0ebc8
Step 6/7 : CMD ruby hasher.rb
---> Running in 9ebdf29452d5
---> 21dc7927f3c2
Removing intermediate container 9ebdf29452d5
Step 7/7 : EXPOSE 80
Step 7/7 : EXPOSE 80
---> Running in d381fa314d6d
---> 96fe8c4598c4
Removing intermediate container d381fa314d6d
Successfully built 96fe8c4598c4
WARNING: Image for service webui was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating dockercoins_hasher_1 ...
Creating dockercoins_redis_1 ...
Creating dockercoins_webui_1 ...
Creating dockercoins_rng_1 ...
Creating dockercoins_worker_1 ...
Creating dockercoins_redis_1
Creating dockercoins_hasher_1
Creating dockercoins_webui_1
Creating dockercoins_rng_1 ... done
Creating dockercoins_worker_1 ... done
Attaching to dockercoins_hasher_1, dockercoins_redis_1, dockercoins_rng_1, dockercoins_webui_1, dockercoins_worker_1
hasher_1 | /usr/local/bundle/gems/thin-1.7.0/lib/thin/server.rb:107: warning: constant ::Fixnum is deprecated
hasher_1 | == Sinatra (v1.4.8) has taken the stage on 80 for development with backup from Thin
redis_1 | 1:C 27 Apr 13:04:37.808 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
#mode detaché
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose up -d
Starting dockercoins_hasher_1 ...
Starting dockercoins_worker_1 ...
Starting dockercoins_redis_1 ...
Starting dockercoins_hasher_1
Starting dockercoins_worker_1
Starting dockercoins_rng_1 ...
Starting dockercoins_redis_1
Starting dockercoins_webui_1 ...
Starting dockercoins_webui_1
Starting dockercoins_webui_1 ... done
root@ird-6-0:~/orchestration-workshop/dockercoins# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8b284f146c95 dockercoins_rng "python rng.py" 2 minutes ago Up 6 seconds 0.0.0.0:8001->80/tcp dockercoins_rng_1
0c824915c99a dockercoins_worker "python worker.py" 2 minutes ago Up 7 seconds dockercoins_worker_1
f241d93dfcd9 redis "docker-entrypoint..." 2 minutes ago Up 7 seconds 6379/tcp dockercoins_redis_1
37cd8025e1a5 dockercoins_webui "node webui.js" 2 minutes ago Up 6 seconds 0.0.0.0:8000->80/tcp dockercoins_webui_1
345fb54677a5 dockercoins_hasher "ruby hasher.rb" 2 minutes ago Up 7 seconds 0.0.0.0:8002->80/tcp dockercoins_hasher_1
a9193bad1623 redis "docker-entrypoint..." 16 minutes ago Up 16 minutes 0.0.0.0:6379->6379/tcp redisdb
2a5da67f7935 registry:2.5 "/entrypoint.sh /e..." 3 hours ago Up 3 hours 0.0.0.0:5000->5000/tcp ecstatic_neumann
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------------
dockercoins_hasher_1 ruby hasher.rb Up 0.0.0.0:8002->80/tcp
dockercoins_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp
dockercoins_rng_1 python rng.py Up 0.0.0.0:8001->80/tcp
dockercoins_webui_1 node webui.js Up 0.0.0.0:8000->80/tcp
dockercoins_worker_1 python worker.py Up
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------------
dockercoins_hasher_1 ruby hasher.rb Up 0.0.0.0:8002->80/tcp
dockercoins_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp
dockercoins_rng_1 python rng.py Up 0.0.0.0:8001->80/tcp
dockercoins_webui_1 node webui.js Up 0.0.0.0:8000->80/tcp
dockercoins_worker_1 python worker.py Up
root@ird-6-0:~/orchestration-workshop/dockercoins#
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose up -d
Starting dockercoins_hasher_1 ...
Starting dockercoins_worker_1 ...
Starting dockercoins_redis_1 ...
Starting dockercoins_hasher_1
Starting dockercoins_worker_1
Starting dockercoins_rng_1 ...
Starting dockercoins_redis_1
Starting dockercoins_webui_1 ...
Starting dockercoins_webui_1
Starting dockercoins_webui_1 ... done
root@ird-6-0:~/orchestration-workshop/dockercoins# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8b284f146c95 dockercoins_rng "python rng.py" 2 minutes ago Up 6 seconds 0.0.0.0:8001->80/tcp dockercoins_rng_1
0c824915c99a dockercoins_worker "python worker.py" 2 minutes ago Up 7 seconds dockercoins_worker_1
f241d93dfcd9 redis "docker-entrypoint..." 2 minutes ago Up 7 seconds 6379/tcp dockercoins_redis_1
37cd8025e1a5 dockercoins_webui "node webui.js" 2 minutes ago Up 6 seconds 0.0.0.0:8000->80/tcp dockercoins_webui_1
345fb54677a5 dockercoins_hasher "ruby hasher.rb" 2 minutes ago Up 7 seconds 0.0.0.0:8002->80/tcp dockercoins_hasher_1
a9193bad1623 redis "docker-entrypoint..." 16 minutes ago Up 16 minutes 0.0.0.0:6379->6379/tcp redisdb
2a5da67f7935 registry:2.5 "/entrypoint.sh /e..." 3 hours ago Up 3 hours 0.0.0.0:5000->5000/tcp ecstatic_neumann
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------------
dockercoins_hasher_1 ruby hasher.rb Up 0.0.0.0:8002->80/tcp
dockercoins_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp
dockercoins_rng_1 python rng.py Up 0.0.0.0:8001->80/tcp
dockercoins_webui_1 node webui.js Up 0.0.0.0:8000->80/tcp
dockercoins_worker_1 python worker.py Up
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------------
dockercoins_hasher_1 ruby hasher.rb Up 0.0.0.0:8002->80/tcp
dockercoins_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp
dockercoins_rng_1 python rng.py Up 0.0.0.0:8001->80/tcp
dockercoins_webui_1 node webui.js Up 0.0.0.0:8000->80/tcp
dockercoins_worker_1 python worker.py Up
root@ird-6-0:~/orchestration-workshop/dockercoins# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8b284f146c95 dockercoins_rng "python rng.py" 5 minutes ago Up 3 minutes 0.0.0.0:8001->80/tcp dockercoins_rng_1
0c824915c99a dockercoins_worker "python worker.py" 5 minutes ago Up 3 minutes dockercoins_worker_1
f241d93dfcd9 redis "docker-entrypoint..." 5 minutes ago Up 3 minutes 6379/tcp dockercoins_redis_1
37cd8025e1a5 dockercoins_webui "node webui.js" 5 minutes ago Up 3 minutes 0.0.0.0:8000->80/tcp dockercoins_webui_1
345fb54677a5 dockercoins_hasher "ruby hasher.rb" 5 minutes ago Up 3 minutes 0.0.0.0:8002->80/tcp dockercoins_hasher_1
a9193bad1623 redis "docker-entrypoint..." 20 minutes ago Up 19 minutes 0.0.0.0:6379->6379/tcp redisdb
2a5da67f7935 registry:2.5 "/entrypoint.sh /e..." 3 hours ago Up 3 hours 0.0.0.0:5000->5000/tcp ecstatic_neumann
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------------
dockercoins_hasher_1 ruby hasher.rb Up 0.0.0.0:8002->80/tcp
dockercoins_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp
dockercoins_rng_1 python rng.py Up 0.0.0.0:8001->80/tcp
dockercoins_webui_1 node webui.js Up 0.0.0.0:8000->80/tcp
dockercoins_worker_1 python worker.py Up
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose logs
Attaching to dockercoins_rng_1, dockercoins_worker_1, dockercoins_redis_1, dockercoins_webui_1, dockercoins_hasher_1
rng_1 | * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
rng_1 | 172.20.0.3 - - [27/Apr/2017 13:04:49] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.3 - - [27/Apr/2017 13:04:49] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.3 - - [27/Apr/2017 13:04:50] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.3 - - [27/Apr/2017 13:04:50] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.3 - - [27/Apr/2017 13:04:50] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.3 - - [27/Apr/2017 13:04:51] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.3 - - [27/Apr/2017 13:04:51] "GET /32 HTTP/1.1" 200 -
asher_1 | 172.20.0.2 - - [27/Apr/2017:13:09:56 +0000] "POST / HTTP/1.1" 200 64 0.1018
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:09:56 +0000] "POST / HTTP/1.1" 200 64 0.1017
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:09:56 +0000] "POST / HTTP/1.1" 200 64 0.1021
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:09:57 +0000] "POST / HTTP/1.1" 200 64 0.1012
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:09:57 +0000] "POST / HTTP/1.1" 200 64 0.1011
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:09:57 +0000] "POST / HTTP/1.1" 200 64 0.1015
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:09:58 +0000] "POST / HTTP/1.1" 200 64 0.1013
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:09:58 +0000] "POST / HTTP/1.1" 200 64 0.1014
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:09:58 +0000] "POST / HTTP/1.1" 200 64 0.1015
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:09:59 +0000] "POST / HTTP/1.1" 200 64 0.1012
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:09:59 +0000] "POST / HTTP/1.1" 200 64 0.1020
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:09:59 +0000] "POST / HTTP/1.1" 200 64 0.1014
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:00 +0000] "POST / HTTP/1.1" 200 64 0.1011
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:00 +0000] "POST / HTTP/1.1" 200 64 0.1012
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:00 +0000] "POST / HTTP/1.1" 200 64 0.1015
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:01 +0000] "POST / HTTP/1.1" 200 64 0.1016
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:01 +0000] "POST / HTTP/1.1" 200 64 0.1013
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:01 +0000] "POST / HTTP/1.1" 200 64 0.1043
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:02 +0000] "POST / HTTP/1.1" 200 64 0.1012
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:02 +0000] "POST / HTTP/1.1" 200 64 0.1010
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:02 +0000] "POST / HTTP/1.1" 200 64 0.1017
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:03 +0000] "POST / HTTP/1.1" 200 64 0.1014
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:03 +0000] "POST / HTTP/1.1" 200 64 0.1016
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:03 +0000] "POST / HTTP/1.1" 200 64 0.1036
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:04 +0000] "POST / HTTP/1.1" 200 64 0.1041
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:04 +0000] "POST / HTTP/1.1" 200 64 0.1022
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:04 +0000] "POST / HTTP/1.1" 200 64 0.1013
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:05 +0000] "POST / HTTP/1.1" 200 64 0.1013
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:05 +0000] "POST / HTTP/1.1" 200 64 0.1010
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:05 +0000] "POST / HTTP/1.1" 200 64 0.1025
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:06 +0000] "POST / HTTP/1.1" 200 64 0.1021
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:06 +0000] "POST / HTTP/1.1" 200 64 0.1018
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:06 +0000] "POST / HTTP/1.1" 200 64 0.1039
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:07 +0000] "POST / HTTP/1.1" 200 64 0.1013
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:07 +0000] "POST / HTTP/1.1" 200 64 0.1012
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:07 +0000] "POST / HTTP/1.1" 200 64 0.1012
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:08 +0000] "POST / HTTP/1.1" 200 64 0.1018
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:08 +0000] "POST / HTTP/1.1" 200 64 0.1015
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:08 +0000] "POST / HTTP/1.1" 200 64 0.1020
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:09 +0000] "POST / HTTP/1.1" 200 64 0.1013
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:09 +0000] "POST / HTTP/1.1" 200 64 0.1021
hasher_1 | 172.20.0.2 - - [27/Apr/2017:13:10:09 +0000] "POST / HTTP/1.1" 200 64 0.1015
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose logs redis
Attaching to dockercoins_redis_1
redis_1 | 1:C 27 Apr 13:04:37.808 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1 | _._
redis_1 | _.-``__ ''-._
redis_1 | _.-`` `. `_. ''-._ Redis 3.2.8 (00000000/0) 64 bit
redis_1 | .-`` .-```. ```\/ _.,_ ''-._
redis_1 | ( ' , .-` | `, ) Running in standalone mode
redis_1 | |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
redis_1 | | `-._ `._ / _.-' | PID: 1
redis_1 | `-._ `-._ `-./ _.-' _.-'
redis_1 | |`-._`-._ `-.__.-' _.-'_.-'|
redis_1 | | `-._`-._ _.-'_.-' | http://redis.io
redis_1 | `-._ `-._`-.__.-'_.-' _.-'
redis_1 | |`-._`-._ `-.__.-' _.-'_.-'|
redis_1 | | `-._`-._ _.-'_.-' |
redis_1 | `-._ `-._`-.__.-'_.-' _.-'
redis_1 | `-._ `-.__.-' _.-'
redis_1 | `-._ _.-'
redis_1 | `-.__.-'
redis_1 |
redis_1 | 1:M 27 Apr 13:04:37.818 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1 | 1:M 27 Apr 13:04:37.818 # Server started, Redis version 3.2.8
redis_1 | 1:M 27 Apr 13:04:37.818 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1 | 1:M 27 Apr 13:04:37.818 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1 | 1:M 27 Apr 13:04:37.818 * The server is now ready to accept connections on port 6379
redis_1 | 1:signal-handler (1493298368) Received SIGTERM scheduling shutdown...
redis_1 | 1:M 27 Apr 13:06:08.654 # User requested shutdown...
redis_1 | 1:M 27 Apr 13:06:08.654 * Saving the final RDB snapshot before exiting.
redis_1 | 1:M 27 Apr 13:06:08.661 * DB saved on disk
redis_1 | 1:M 27 Apr 13:06:08.661 # Redis is now ready to exit, bye bye...
redis_1 | 1:C 27 Apr 13:06:33.544 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1 | _._
redis_1 | _.-``__ ''-._
redis_1 | _.-`` `. `_. ''-._ Redis 3.2.8 (00000000/0) 64 bit
redis_1 | .-`` .-```. ```\/ _.,_ ''-._
redis_1 | ( ' , .-` | `, ) Running in standalone mode
redis_1 | |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
redis_1 | | `-._ `._ / _.-' | PID: 1
redis_1 | `-._ `-._ `-./ _.-' _.-'
redis_1 | |`-._`-._ `-.__.-' _.-'_.-'|
redis_1 | | `-._`-._ _.-'_.-' | http://redis.io
redis_1 | `-._ `-._`-.__.-'_.-' _.-'
redis_1 | |`-._`-._ `-.__.-' _.-'_.-'|
redis_1 | | `-._`-._ _.-'_.-' |
redis_1 | `-._ `-._`-.__.-'_.-' _.-'
redis_1 | `-._ `-.__.-' _.-'
redis_1 | `-._ _.-'
redis_1 | `-.__.-'
redis_1 |
redis_1 | 1:M 27 Apr 13:06:33.570 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1 | 1:M 27 Apr 13:06:33.571 # Server started, Redis version 3.2.8
redis_1 | 1:M 27 Apr 13:06:33.571 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1 | 1:M 27 Apr 13:06:33.571 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1 | 1:M 27 Apr 13:06:33.572 * DB loaded from disk: 0.000 seconds
redis_1 | 1:M 27 Apr 13:06:33.572 * The server is now ready to accept connections on port 6379
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose logs --follow --tail 20 rng
Attaching to dockercoins_rng_1
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:49] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:49] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:49] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:50] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:50] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:50] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:51] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:51] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:51] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:51] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:52] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:52] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:52] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:53] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:53] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:53] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:54] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:54] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:54] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:55] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:55] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:55] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:56] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:56] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:56] "GET /32 HTTP/1.1" 200 -
rng_1 | 172.20.0.2 - - [27/Apr/2017 13:10:57] "GET /32 HTTP/1.1" 200 -
^Z
[2]+ Stopped docker-compose logs --follow --tail 20 rng
root@ird-6-0:~/orchestration-workshop/dockercoins#
### a remonter
webui:
build: webui
ports:
- "8080:80"
volumes:
- "./webui/files/:/files/"
http://159.203.67.250:8080/index.html
#### scale 8.7
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose scale worker=2
Starting dockercoins_worker_1 ... done
Creating dockercoins_worker_2 ...
Creating dockercoins_worker_2 ... done
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------------
dockercoins_hasher_1 ruby hasher.rb Up 0.0.0.0:8002->80/tcp
dockercoins_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp
dockercoins_rng_1 python rng.py Up 0.0.0.0:8001->80/tcp
dockercoins_webui_1 node webui.js Up 0.0.0.0:8080->80/tcp
dockercoins_worker_1 python worker.py Up
dockercoins_worker_2 python worker.py Up
root@ird-6-0:~/orchestration-workshop/dockercoins#
root@ird-6-0:~/orchestration-workshop/dockercoins# apt-get install httping
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
snap-confine
Use 'apt autoremove' to remove it.
The following NEW packages will be installed:
httping
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.
Need to get 43.8 kB of archives.
After this operation, 121 kB of additional disk space will be used.
Get:1 http://mirrors.digitalocean.com/ubuntu xenial/universe amd64 httping amd64 2.4-1 [43.8 kB]
Fetched 43.8 kB in 0s (1,747 kB/s)
Selecting previously unselected package httping.
(Reading database ... 107117 files and directories currently installed.)
Preparing to unpack .../httping_2.4-1_amd64.deb ...
Unpacking httping (2.4-1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up httping (2.4-1) ...
root@ird-6-0:~/orchestration-workshop/dockercoins# httping -c 10 localhost:8001
PING localhost:8001 (/):
connected to 127.0.0.1:8001 (158 bytes), seq=0 time=801.54 ms
connected to 127.0.0.1:8001 (158 bytes), seq=1 time=821.71 ms
connected to 127.0.0.1:8001 (158 bytes), seq=2 time=843.52 ms
connected to 127.0.0.1:8001 (158 bytes), seq=3 time=874.05 ms
connected to 127.0.0.1:8001 (158 bytes), seq=4 time=854.44 ms
connected to 127.0.0.1:8001 (158 bytes), seq=5 time=759.73 ms
^Z
[3]+ Stopped httping -c 10 localhost:8001
root@ird-6-0:~/orchestration-workshop/dockercoins# httping -c 10 localhost:8002
PING localhost:8002 (/):
connected to 127.0.0.1:8002 (210 bytes), seq=0 time= 6.54 ms
connected to 127.0.0.1:8002 (210 bytes), seq=1 time= 4.34 ms
connected to 127.0.0.1:8002 (210 bytes), seq=2 time= 8.66 ms
connected to 127.0.0.1:8002 (210 bytes), seq=3 time= 4.02 ms
connected to 127.0.0.1:8002 (210 bytes), seq=4 time= 3.24 ms
connected to 127.0.0.1:8002 (210 bytes), seq=5 time= 4.99 ms
connected to 127.0.0.1:8002 (210 bytes), seq=6 time= 3.68 ms
connected to 127.0.0.1:8002 (210 bytes), seq=7 time= 3.78 ms
^Z
[4]+ Stopped httping -c 10 localhost:8002
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose ps
Name Command State Ports
-------------------------------------------------------------------------------------
dockercoins_hasher_1 ruby hasher.rb Up 0.0.0.0:8002->80/tcp
dockercoins_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp
dockercoins_rng_1 python rng.py Up 0.0.0.0:8001->80/tcp
dockercoins_webui_1 node webui.js Up 0.0.0.0:8080->80/tcp
dockercoins_worker_1 python worker.py Up
dockercoins_worker_10 python worker.py Up
dockercoins_worker_2 python worker.py Up
dockercoins_worker_3 python worker.py Up
dockercoins_worker_4 python worker.py Up
dockercoins_worker_5 python worker.py Up
dockercoins_worker_6 python worker.py Up
dockercoins_worker_7 python worker.py Up
dockercoins_worker_8 python worker.py Up
dockercoins_worker_9 python worker.py Up
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose images
Container Repository Tag Image Id Size
----------------------------------------------------------------------------
dockercoins_hasher_1 dockercoins_hasher latest 363a9620dc8f 216 MB
dockercoins_redis_1 redis latest e32ef7250bc1 175 MB
dockercoins_rng_1 dockercoins_rng latest c01b58a6bac5 94.9 MB
dockercoins_webui_1 dockercoins_webui latest 96fe8c4598c4 205 MB
dockercoins_worker_1 dockercoins_worker latest 8f659dafe3dd 92.5 MB
dockercoins_worker_10 dockercoins_worker latest 8f659dafe3dd 92.5 MB
dockercoins_worker_2 dockercoins_worker latest 8f659dafe3dd 92.5 MB
dockercoins_worker_3 dockercoins_worker latest 8f659dafe3dd 92.5 MB
dockercoins_worker_4 dockercoins_worker latest 8f659dafe3dd 92.5 MB
dockercoins_worker_5 dockercoins_worker latest 8f659dafe3dd 92.5 MB
dockercoins_worker_6 dockercoins_worker latest 8f659dafe3dd 92.5 MB
dockercoins_worker_7 dockercoins_worker latest 8f659dafe3dd 92.5 MB
dockercoins_worker_8 dockercoins_worker latest 8f659dafe3dd 92.5 MB
dockercoins_worker_9 dockercoins_worker latest 8f659dafe3dd 92.5 MB
root@ird-6-0:~/orchestration-workshop/dockercoins#
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose dowb
No such command: dowb
Commands:
build Build or rebuild services
bundle Generate a Docker bundle from the Compose file
config Validate and view the compose file
create Create services
down Stop and remove containers, networks, images, and volumes
events Receive real time events from containers
exec Execute a command in a running container
help Get help on a command
images List images
kill Kill containers
logs View output from containers
pause Pause services
port Print the public port for a port binding
ps List containers
pull Pull service images
push Push service images
restart Restart services
rm Remove stopped containers
run Run a one-off command
scale Set number of containers for a service
start Start services
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker-Compose version information
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose down
Stopping dockercoins_worker_9 ... done
Stopping dockercoins_worker_10 ... done
Stopping dockercoins_worker_8 ... done
Stopping dockercoins_worker_7 ... done
Stopping dockercoins_worker_4 ... done
Stopping dockercoins_worker_6 ... done
Stopping dockercoins_worker_5 ... done
Stopping dockercoins_worker_3 ... done
Stopping dockercoins_worker_2 ... done
Stopping dockercoins_webui_1 ... done
Stopping dockercoins_rng_1 ... done
Stopping dockercoins_worker_1 ... done
Stopping dockercoins_redis_1 ... done
Stopping dockercoins_hasher_1 ... done
Removing dockercoins_worker_9 ... done
Removing dockercoins_worker_10 ... done
Removing dockercoins_worker_8 ... done
Removing dockercoins_worker_7 ... done
Removing dockercoins_worker_4 ... done
Removing dockercoins_worker_6 ... done
Removing dockercoins_worker_5 ... done
Removing dockercoins_worker_3 ... done
Removing dockercoins_worker_2 ... done
Removing dockercoins_webui_1 ... done
Removing dockercoins_rng_1 ... done
Removing dockercoins_worker_1 ... done
Removing dockercoins_redis_1 ... done
Removing dockercoins_hasher_1 ... done
Removing network dockercoins_default
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose ps
Name Command State Ports
------------------------------
root@ird-6-0:~/orchestration-workshop/dockercoins#
...
# Promote some nodes
root@ird-6-0:~# docker node promote ird-6-1
Node ird-6-1 promoted to a manager in the swarm.
root@ird-6-0:~# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
3b489jzzdc9shihz37g1buz41 ird-6-1 Ready Active Reachable
4xu1niz6wea3cwzpdlhc0n1x3 * ird-6-0 Ready Active Leader
veyc81zqcl039t07yoau6xdzp ird-6-2 Ready Active
root@ird-6-0:~# docker node promote ird-6-2
Node ird-6-2 promoted to a manager in the swarm.
root@ird-6-0:~# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
3b489jzzdc9shihz37g1buz41 ird-6-1 Ready Active Reachable
4xu1niz6wea3cwzpdlhc0n1x3 * ird-6-0 Ready Active Leader
veyc81zqcl039t07yoau6xdzp ird-6-2 Ready Active Reachable
root@ird-6-0:~#
root@ird-6-0:~# docker service create alpine ping 8.8.8.8
rl9fxjroqvsgtxqwqxhn2zkf0
root@ird-6-0:~# docker service ps rl9fxjroqvsgtxqwqxhn2zkf0
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
l7pqmar6vvq1 gifted_meitner.1 alpine:latest ird-6-0 Running Running 19 seconds ago
root@ird-6-0:~#
root@ird-6-0:~# docker service create alpine ping 8.8.8.8
root@ird-6-0:~# docker service ps rl9fxjroqvsgtxqwqxhn2zkf0
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
l7pqmar6vvq1 gifted_meitner.1 alpine:latest ird-6-0 Running Running 19 seconds ago
root@ird-6-0:~#
#scale
root@ird-6-0:~# docker service ls
ID NAME MODE REPLICAS IMAGE
r5kkirqhbqz8 determined_almeida replicated 8/8 alpine:latest
root@ird-6-0:~# docker service ps r5kkirqhbqz8
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
jba3fvwdoqrb determined_almeida.1 alpine:latest ird-6-2 Running Running 5 minutes ago
y8s6n9c01jwc determined_almeida.2 alpine:latest ird-6-1 Running Running 17 seconds ago
rwmkty9flc0j determined_almeida.3 alpine:latest ird-6-0 Running Running 18 seconds ago
nlpg2uq60f7y determined_almeida.4 alpine:latest ird-6-2 Running Running 18 seconds ago
3jihp5o1tlqd determined_almeida.5 alpine:latest ird-6-1 Running Running 17 seconds ago
ittt9gyzjx4a determined_almeida.6 alpine:latest ird-6-0 Running Running 17 seconds ago
dxziiho6gjjl determined_almeida.7 alpine:latest ird-6-0 Running Running 18 seconds ago
eh0zvbdbfjuf determined_almeida.8 alpine:latest ird-6-2 Running Running 18 seconds ago
root@ird-6-0:~#
# node1
root@ird-6-1:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d8d91c6a1050 alpine:latest "ping 8.8.8.8" 54 seconds ago Up 53 seconds determined_almeida.5.3jihp5o1tlqdpa5g242wxsbgr
90a3714a95ce alpine:latest "ping 8.8.8.8" 55 seconds ago Up 53 seconds determined_almeida.2.y8s6n9c01jwcg06ld9azuu7p8
root@ird-6-1:~#
# services and ports
Deploying aookication on Swarm
root@ird-6-0:~# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username (18092004):
Password:
Login Succeeded
root@ird-6-0:~# cd orchestration-workshop/dockercoins/
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-co
docker-compose docker-containerd docker-containerd-ctr docker-containerd-shim
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-co
docker-compose docker-containerd docker-containerd-ctr docker-containerd-shim
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose build hasher
Building hasher
Step 1/7 : FROM ruby:alpine
---> 5eadd5d1419a
Step 2/7 : RUN apk add --update build-base
---> Using cache
---> 9be58770e7bc
Step 3/7 : RUN gem install sinatra
---> Using cache
---> 43122e414a51
Step 4/7 : RUN gem install thin
---> Using cache
---> 483895eeabc2
Step 5/7 : ADD hasher.rb /
---> Using cache
---> b136b624da2a
Step 6/7 : CMD ruby hasher.rb
---> Using cache
---> 21dc7927f3c2
Step 7/7 : EXPOSE 80
---> Using cache
---> 363a9620dc8f
Successfully built 363a9620dc8f
root@ird-6-0:~/orchestration-workshop/dockercoins# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a9193bad1623 redis "docker-entrypoint..." 19 hours ago Up 19 hours 0.0.0.0:6379->6379/tcp redisdb
2a5da67f7935 registry:2.5 "/entrypoint.sh /e..." 22 hours ago Up 22 hours 0.0.0.0:5000->5000/tcp ecstatic_neumann
root@ird-6-0:~/orchestration-workshop/dockercoins# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
dockercoins_webui latest 96fe8c4598c4 19 hours ago 215MB
dockercoins_rng latest c01b58a6bac5 19 hours ago 99.5MB
dockercoins_hasher latest 363a9620dc8f 19 hours ago 226MB
dockercoins_worker latest 8f659dafe3dd 19 hours ago 97MB
inventory-service latest 815296d633c1 19 hours ago 221MB
<none> <none> 2a7697959ab6 19 hours ago 221MB
18092004/trustedubuntu 1.0 b24aed948f42 23 hours ago 117MB
elasticsearch <none> 0b44dca495a2 32 hours ago 352MB
python alpine 02dcd3de5240 36 hours ago 88.9MB
myimage latest 6ad0afd0e636 42 hours ago 259MB
tranchant/myimage 10.1 6ad0afd0e636 42 hours ago 259MB
test 1.0 dc66e7a6ac88 46 hours ago 188MB
18092004/javahelloworld 1.1 a6121ec6a6c4 46 hours ago 584MB
18092004/javahelloworld 1.0 91473d3b8a90 47 hours ago 584MB
tranchant/mynewjava 1.0 91473d3b8a90 47 hours ago 584MB
<none> <none> 0b4cf47b7c50 47 hours ago 584MB
<none> <none> 3d7b25481bda 47 hours ago 584MB
<none> <none> bf1fe4d91e25 47 hours ago 584MB
<none> <none> 73facd5d728a 2 days ago 584MB
tranchant/mynewimage 1.0 1cb383192409 2 days ago 259MB
<none> <none> 29d150b1bfed 2 days ago 259MB
<none> <none> 227336e84e7a 2 days ago 259MB
<none> <none> 5e3ec5deaf88 2 days ago 260MB
<none> <none> d02c8732fe4c 2 days ago 260MB
tranchant/myimage 1.1 2bb7abf1ab43 2 days ago 259MB
18092004/myimage 1.0 06bf6c7e7ce0 2 days ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 2 days ago 259MB
redis latest e32ef7250bc1 3 days ago 184MB
node slim 754e0c30495a 3 days ago 220MB
node 4-slim 112daf73658e 3 days ago 210MB
tomcat latest 1f6eab5f63d3 3 days ago 367MB
18092004/trustedubuntu latest f7b3f317ec73 3 days ago 117MB
ubuntu latest f7b3f317ec73 3 days ago 117MB
ubuntu 14.04 302fa07d8117 2 weeks ago 188MB
centos 7 a8493f5f50ff 3 weeks ago 192MB
nginx latest 5766334bdaa0 3 weeks ago 183MB
ruby alpine 5eadd5d1419a 5 weeks ago 56.3MB
busybox latest 00f017a8c2a6 7 weeks ago 1.11MB
localhost:5000/tranchant/mybusybox 1.0 00f017a8c2a6 7 weeks ago 1.11MB
localhost:5000/tranchant/mybusybox 1.1 00f017a8c2a6 7 weeks ago 1.11MB
alpine <none> 4a415e366388 7 weeks ago 3.99MB
java 7 5dc48a6b75af 3 months ago 584MB
registry 2.5 182810e6ba8c 4 months ago 37.6MB
trainingteam/nginx latest 7a1b7351fc6b 7 months ago 183MB
robtec/webdis <none> 9ed2bcc42ba8 10 months ago 300MB
root@ird-6-0:~/orchestration-workshop/dockercoins# docker tag dockercoins_hasher
dockercoins_hasher dockercoins_hasher:latest
root@ird-6-0:~/orchestration-workshop/dockercoins# docker tag dockercoins_hasher 18092004/dockercoins_hasher:1.0
root@ird-6-0:~/orchestration-workshop/dockercoins# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
dockercoins_webui latest 96fe8c4598c4 19 hours ago 215MB
dockercoins_rng latest c01b58a6bac5 19 hours ago 99.5MB
18092004/dockercoins_hasher 1.0 363a9620dc8f 19 hours ago 226MB
dockercoins_hasher latest 363a9620dc8f 19 hours ago 226MB
dockercoins_worker latest 8f659dafe3dd 19 hours ago 97MB
inventory-service latest 815296d633c1 19 hours ago 221MB
<none> <none> 2a7697959ab6 19 hours ago 221MB
18092004/trustedubuntu 1.0 b24aed948f42 23 hours ago 117MB
elasticsearch <none> 0b44dca495a2 32 hours ago 352MB
python alpine 02dcd3de5240 36 hours ago 88.9MB
tranchant/myimage 10.1 6ad0afd0e636 42 hours ago 259MB
myimage latest 6ad0afd0e636 42 hours ago 259MB
test 1.0 dc66e7a6ac88 46 hours ago 188MB
18092004/javahelloworld 1.1 a6121ec6a6c4 46 hours ago 584MB
18092004/javahelloworld 1.0 91473d3b8a90 47 hours ago 584MB
tranchant/mynewjava 1.0 91473d3b8a90 47 hours ago 584MB
<none> <none> 0b4cf47b7c50 47 hours ago 584MB
<none> <none> 3d7b25481bda 47 hours ago 584MB
<none> <none> bf1fe4d91e25 47 hours ago 584MB
<none> <none> 73facd5d728a 2 days ago 584MB
tranchant/mynewimage 1.0 1cb383192409 2 days ago 259MB
<none> <none> 29d150b1bfed 2 days ago 259MB
<none> <none> 227336e84e7a 2 days ago 259MB
<none> <none> 5e3ec5deaf88 2 days ago 260MB
<none> <none> d02c8732fe4c 2 days ago 260MB
tranchant/myimage 1.1 2bb7abf1ab43 2 days ago 259MB
18092004/myimage 1.0 06bf6c7e7ce0 2 days ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 2 days ago 259MB
redis latest e32ef7250bc1 3 days ago 184MB
node slim 754e0c30495a 3 days ago 220MB
node 4-slim 112daf73658e 3 days ago 210MB
tomcat latest 1f6eab5f63d3 3 days ago 367MB
18092004/trustedubuntu latest f7b3f317ec73 3 days ago 117MB
ubuntu latest f7b3f317ec73 3 days ago 117MB
ubuntu 14.04 302fa07d8117 2 weeks ago 188MB
centos 7 a8493f5f50ff 3 weeks ago 192MB
nginx latest 5766334bdaa0 3 weeks ago 183MB
ruby alpine 5eadd5d1419a 5 weeks ago 56.3MB
busybox latest 00f017a8c2a6 7 weeks ago 1.11MB
localhost:5000/tranchant/mybusybox 1.0 00f017a8c2a6 7 weeks ago 1.11MB
localhost:5000/tranchant/mybusybox 1.1 00f017a8c2a6 7 weeks ago 1.11MB
alpine <none> 4a415e366388 7 weeks ago 3.99MB
java 7 5dc48a6b75af 3 months ago 584MB
registry 2.5 182810e6ba8c 4 months ago 37.6MB
trainingteam/nginx latest 7a1b7351fc6b 7 months ago 183MB
robtec/webdis <none> 9ed2bcc42ba8 10 months ago 300MB
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-co
docker-compose docker-containerd docker-containerd-ctr docker-containerd-shim
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-co
docker-compose docker-containerd docker-containerd-ctr docker-containerd-shim
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-co
docker-compose docker-containerd docker-containerd-ctr docker-containerd-shim
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose build rng
Building rng
Step 1/5 : FROM python:alpine
---> 02dcd3de5240
Step 2/5 : RUN pip install Flask
---> Using cache
---> 563900d4486f
Step 3/5 : COPY rng.py /
---> Using cache
---> 295aad1ae9ee
Step 4/5 : CMD python rng.py
---> Using cache
---> 90eb894c59bd
Step 5/5 : EXPOSE 80
---> Using cache
---> c01b58a6bac5
Successfully built c01b58a6bac5
root@ird-6-0:~/orchestration-workshop/dockercoins# docker tag dockercoins_rng 18092004/dockercoins_rng:1.0
root@ird-6-0:~/orchestration-workshop/dockercoins# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
dockercoins_webui latest 96fe8c4598c4 19 hours ago 215MB
18092004/dockercoins_rng 1.0 c01b58a6bac5 19 hours ago 99.5MB
dockercoins_rng latest c01b58a6bac5 19 hours ago 99.5MB
dockercoins_hasher latest 363a9620dc8f 19 hours ago 226MB
18092004/dockercoins_hasher 1.0 363a9620dc8f 19 hours ago 226MB
dockercoins_worker latest 8f659dafe3dd 19 hours ago 97MB
inventory-service latest 815296d633c1 19 hours ago 221MB
<none> <none> 2a7697959ab6 19 hours ago 221MB
18092004/trustedubuntu 1.0 b24aed948f42 23 hours ago 117MB
elasticsearch <none> 0b44dca495a2 32 hours ago 352MB
python alpine 02dcd3de5240 36 hours ago 88.9MB
tranchant/myimage 10.1 6ad0afd0e636 42 hours ago 259MB
myimage latest 6ad0afd0e636 42 hours ago 259MB
test 1.0 dc66e7a6ac88 46 hours ago 188MB
18092004/javahelloworld 1.1 a6121ec6a6c4 46 hours ago 584MB
18092004/javahelloworld 1.0 91473d3b8a90 47 hours ago 584MB
tranchant/mynewjava 1.0 91473d3b8a90 47 hours ago 584MB
<none> <none> 0b4cf47b7c50 47 hours ago 584MB
<none> <none> 3d7b25481bda 47 hours ago 584MB
<none> <none> bf1fe4d91e25 47 hours ago 584MB
<none> <none> 73facd5d728a 2 days ago 584MB
tranchant/mynewimage 1.0 1cb383192409 2 days ago 259MB
<none> <none> 29d150b1bfed 2 days ago 259MB
<none> <none> 227336e84e7a 2 days ago 259MB
<none> <none> 5e3ec5deaf88 2 days ago 260MB
<none> <none> d02c8732fe4c 2 days ago 260MB
tranchant/myimage 1.1 2bb7abf1ab43 2 days ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 2 days ago 259MB
18092004/myimage 1.0 06bf6c7e7ce0 2 days ago 259MB
redis latest e32ef7250bc1 3 days ago 184MB
node slim 754e0c30495a 3 days ago 220MB
node 4-slim 112daf73658e 3 days ago 210MB
tomcat latest 1f6eab5f63d3 3 days ago 367MB
18092004/trustedubuntu latest f7b3f317ec73 3 days ago 117MB
ubuntu latest f7b3f317ec73 3 days ago 117MB
ubuntu 14.04 302fa07d8117 2 weeks ago 188MB
centos 7 a8493f5f50ff 3 weeks ago 192MB
nginx latest 5766334bdaa0 3 weeks ago 183MB
ruby alpine 5eadd5d1419a 5 weeks ago 56.3MB
busybox latest 00f017a8c2a6 7 weeks ago 1.11MB
localhost:5000/tranchant/mybusybox 1.0 00f017a8c2a6 7 weeks ago 1.11MB
localhost:5000/tranchant/mybusybox 1.1 00f017a8c2a6 7 weeks ago 1.11MB
alpine <none> 4a415e366388 7 weeks ago 3.99MB
java 7 5dc48a6b75af 3 months ago 584MB
registry 2.5 182810e6ba8c 4 months ago 37.6MB
trainingteam/nginx latest 7a1b7351fc6b 7 months ago 183MB
robtec/webdis <none> 9ed2bcc42ba8 10 months ago 300MB
root@ird-6-0:~/orchestration-workshop/dockercoins# docker-compose build webui
Building webui
Step 1/7 : FROM node:4-slim
---> 112daf73658e
Step 2/7 : RUN npm install express
---> Using cache
---> b20b3598c735
Step 3/7 : RUN npm install redis
---> Using cache
---> 60f941c369d2
Step 4/7 : COPY files/ /files/
---> Using cache
---> 29077b4f9cf9
Step 5/7 : COPY webui.js /
---> Using cache
---> a2c6e813fdd5
Step 6/7 : CMD node webui.js
---> Using cache
---> 14e5851c3972
Step 7/7 : EXPOSE 80
---> Using cache
---> 96fe8c4598c4
Successfully built 96fe8c4598c4
root@ird-6-0:~/orchestration-workshop/dockercoins# docker tag dockercoins_webui 18092004/dockercoins_webui:1.0
root@ird-6-0:~/orchestration-workshop/dockercoins# docker tag dockercoins_worker 18092004/dockercoins_worker:1.0
root@ird-6-0:~/orchestration-workshop/dockercoins# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
18092004/dockercoins_webui 1.0 96fe8c4598c4 19 hours ago 215MB
dockercoins_webui latest 96fe8c4598c4 19 hours ago 215MB
18092004/dockercoins_rng 1.0 c01b58a6bac5 19 hours ago 99.5MB
dockercoins_rng latest c01b58a6bac5 19 hours ago 99.5MB
18092004/dockercoins_hasher 1.0 363a9620dc8f 19 hours ago 226MB
dockercoins_hasher latest 363a9620dc8f 19 hours ago 226MB
18092004/dockercoins_worker 1.0 8f659dafe3dd 19 hours ago 97MB
dockercoins_worker latest 8f659dafe3dd 19 hours ago 97MB
inventory-service latest 815296d633c1 19 hours ago 221MB
<none> <none> 2a7697959ab6 20 hours ago 221MB
18092004/trustedubuntu 1.0 b24aed948f42 23 hours ago 117MB
elasticsearch <none> 0b44dca495a2 32 hours ago 352MB
python alpine 02dcd3de5240 36 hours ago 88.9MB
myimage latest 6ad0afd0e636 42 hours ago 259MB
tranchant/myimage 10.1 6ad0afd0e636 42 hours ago 259MB
test 1.0 dc66e7a6ac88 46 hours ago 188MB
18092004/javahelloworld 1.1 a6121ec6a6c4 46 hours ago 584MB
18092004/javahelloworld 1.0 91473d3b8a90 47 hours ago 584MB
tranchant/mynewjava 1.0 91473d3b8a90 47 hours ago 584MB
<none> <none> 0b4cf47b7c50 47 hours ago 584MB
<none> <none> 3d7b25481bda 47 hours ago 584MB
<none> <none> bf1fe4d91e25 2 days ago 584MB
<none> <none> 73facd5d728a 2 days ago 584MB
tranchant/mynewimage 1.0 1cb383192409 2 days ago 259MB
<none> <none> 29d150b1bfed 2 days ago 259MB
<none> <none> 227336e84e7a 2 days ago 259MB
<none> <none> 5e3ec5deaf88 2 days ago 260MB
<none> <none> d02c8732fe4c 2 days ago 260MB
tranchant/myimage 1.1 2bb7abf1ab43 2 days ago 259MB
18092004/myimage 1.0 06bf6c7e7ce0 2 days ago 259MB
tranchant/myimage 1.0 06bf6c7e7ce0 2 days ago 259MB
redis latest e32ef7250bc1 3 days ago 184MB
node slim 754e0c30495a 3 days ago 220MB
node 4-slim 112daf73658e 3 days ago 210MB
tomcat latest 1f6eab5f63d3 3 days ago 367MB
18092004/trustedubuntu latest f7b3f317ec73 3 days ago 117MB
ubuntu latest f7b3f317ec73 3 days ago 117MB
ubuntu 14.04 302fa07d8117 2 weeks ago 188MB
centos 7 a8493f5f50ff 3 weeks ago 192MB
nginx latest 5766334bdaa0 3 weeks ago 183MB
ruby alpine 5eadd5d1419a 5 weeks ago 56.3MB
busybox latest 00f017a8c2a6 7 weeks ago 1.11MB
localhost:5000/tranchant/mybusybox 1.0 00f017a8c2a6 7 weeks ago 1.11MB
localhost:5000/tranchant/mybusybox 1.1 00f017a8c2a6 7 weeks ago 1.11MB
alpine <none> 4a415e366388 7 weeks ago 3.99MB
java 7 5dc48a6b75af 3 months ago 584MB
registry 2.5 182810e6ba8c 4 months ago 37.6MB
trainingteam/nginx latest 7a1b7351fc6b 7 months ago 183MB
robtec/webdis <none> 9ed2bcc42ba8 10 months ago 300MB
root@ird-6-0:~/orchestration-workshop/dockercoins#
root@ird-6-0:~/orchestration-workshop/dockercoins# docker push 18092004/dockercoins_hasher:1.0
The push refers to a repository [docker.io/18092004/dockercoins_hasher]
66d961164d0a: Pushed
617f4380e2c2: Pushed
5d1a07148c05: Pushed
deecbb7dbe6c: Pushed
05f882941028: Mounted from library/ruby
e07bfdb2a934: Mounted from library/ruby
0598949a9cab: Mounted from library/ruby
7b1b6293e1d4: Mounted from library/ruby
9f8566ee5135: Mounted from library/ruby
1.0: digest: sha256:f3021fff97204a8f4c0b007e44927decddc77030c13256e2ba5d18f1b04ced57 size: 2205
root@ird-6-0:~/orchestration-workshop/dockercoins# docker push 18092004/dockercoins_rng
18092004/dockercoins_rng 18092004/dockercoins_rng:1.0
root@ird-6-0:~/orchestration-workshop/dockercoins# docker push 18092004/dockercoins_rng:1.0
The push refers to a repository [docker.io/18092004/dockercoins_rng]
e8b0ef269d0a: Pushed
ccd13231b1ac: Pushed
cf1782ee6739: Mounted from library/python
3cacaf09fa56: Mounted from library/python
af4997faab5b: Mounted from library/python
9f8566ee5135: Mounted from 18092004/dockercoins_hasher
1.0: digest: sha256:6a96037db81a1139676b7b02dc50bba0c84961edcfa22b82257f547eaf619db0 size: 1575
root@ird-6-0:~/orchestration-workshop/dockercoins# docker push 18092004/dockercoins_webui:1.0
The push refers to a repository [docker.io/18092004/dockercoins_webui]
668858c595fa: Pushed
251fa0018033: Pushed
38817412f3ca: Pushed
106c9cd72c81: Pushed
a3214043a02d: Mounted from library/node
83767870500e: Mounted from library/node
c694e253d6c7: Mounted from library/node
9dfe0682ca78: Mounted from library/node
682e7cee9d37: Mounted from library/elasticsearch
295d6a056bfd: Mounted from library/elasticsearch
1.0: digest: sha256:14f1c8bf0af947ef036ff38dc159755c37f76b82837afa98480d4e3a7e4ee845 size: 2419
root@ird-6-0:~/orchestration-workshop/dockercoins#
root@ird-6-0:~/orchestration-workshop/dockercoins# docker push 18092004/dockercoins_webui:1.0
The push refers to a repository [docker.io/18092004/dockercoins_webui]
668858c595fa: Pushed
251fa0018033: Pushed
38817412f3ca: Pushed
106c9cd72c81: Pushed
a3214043a02d: Mounted from library/node
83767870500e: Mounted from library/node
c694e253d6c7: Mounted from library/node
9dfe0682ca78: Mounted from library/node
682e7cee9d37: Mounted from library/elasticsearch
295d6a056bfd: Mounted from library/elasticsearch
1.0: digest: sha256:14f1c8bf0af947ef036ff38dc159755c37f76b82837afa98480d4e3a7e4ee845 size: 2419
root@ird-6-0:~/orchestration-workshop/dockercoins# docker push 18092004/dockercoins_worker
18092004/dockercoins_worker 18092004/dockercoins_worker:1.0
root@ird-6-0:~/orchestration-workshop/dockercoins# docker push 18092004/dockercoins_worker
18092004/dockercoins_worker 18092004/dockercoins_worker:1.0
root@ird-6-0:~/orchestration-workshop/dockercoins# docker push 18092004/dockercoins_worker
18092004/dockercoins_worker 18092004/dockercoins_worker:1.0
root@ird-6-0:~/orchestration-workshop/dockercoins# docker push 18092004/dockercoins_worker:1.0
The push refers to a repository [docker.io/18092004/dockercoins_worker]
234b2e2eb671: Pushed
9cd2c92aeb9c: Pushed
309a7085dac4: Pushed
cf1782ee6739: Mounted from 18092004/dockercoins_rng
3cacaf09fa56: Mounted from 18092004/dockercoins_rng
af4997faab5b: Mounted from 18092004/dockercoins_rng
9f8566ee5135: Mounted from 18092004/dockercoins_rng
1.0: digest: sha256:51211b03b669d7ccce2b0c8f5cdf4650a26d64e936e6d2f5a7559bb587ba1018 size: 1786
root@ird-6-0:~/orchestration-workshop/dockercoins#
root@ird-6-0:~/orchestration-workshop/dockercoins# docker network create --driver overlay dockercoins
lhzkxsjzf43b3sbocb4vbv53q
root@ird-6-0:~/orchestration-workshop/dockercoins# docker network ls
NETWORK ID NAME DRIVER SCOPE
bcdc626653fa bridge bridge local
957140d1bfb5 docker_gwbridge bridge local
lhzkxsjzf43b dockercoins overlay swarm
11d63bd3106c host host local
wl2l32ylbezo ingress overlay swarm
ded4841859fd my_bridge bridge local
b7005d130b33 nodeapp bridge local
691b702b8f08 none null local
root@ird-6-0:~/orchestration-workshop/dockercoins#
root@ird-6-0:~/orchestration-workshop/dockercoins#
root@ird-6-0:~/orchestration-workshop/dockercoins# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
3b489jzzdc9shihz37g1buz41 ird-6-1 Ready Active Reachable
4xu1niz6wea3cwzpdlhc0n1x3 * ird-6-0 Ready Active Leader
veyc81zqcl039t07yoau6xdzp ird-6-2 Ready Active Reachable
root@ird-6-0:~/orchestration-workshop/dockercoins#
#node1
# si worker,on voit pas le reseau overlay (juste manager)
root@ird-6-1:~# docker network ls
NETWORK ID NAME DRIVER SCOPE
c7a0217af113 bridge bridge local
8f77e0a28ad6 docker_gwbridge bridge local
lhzkxsjzf43b dockercoins overlay swarm
7aaf6c7354d8 host host local
wl2l32ylbezo ingress overlay swarm
39f194fc661b none null local
root@ird-6-1:~#
#Ex9.10 modifié
#version qui supporte swarm
version: "3"
services:
rng:
#build: rng
image: 18092004/dockercoins_rng:1.0
ports:
- "8001:80"
hasher:
#build: hasher
image: 18092004/dockercoins_hasher:1.0
ports:
- "8002:80"
webui:
#build: webui
image: 18092004/dockercoins_webui:1.0
ports:
- "8080:80"
volumes:
- "./webui/files/:/files/"
redis:
image: redis
worker:
#build: worker
image: 18092004/dockercoins_worker:1.0
# uti docker compose pour lancer tous les services (nouvelle version alors que l ancienne version manuellement, service par service)
# cree le reseau automatiquement overlay en mode swarm
# pour lancer les services sur l ensemble des noeuds et pas un seul comme avec docker-compose up -d
root@ird-6-0:~/orchestration-workshop/dockercoins# docker stack deploy -c docker-compose.yml tartampion
Creating network tartampion_default
Creating service tartampion_hasher
Creating service tartampion_webui
Creating service tartampion_redis
Creating service tartampion_worker
Creating service tartampion_rng
root@ird-6-0:~/orchestration-workshop/dockercoins#
root@ird-6-0:~/orchestration-workshop/dockercoins# docker service ls
ID NAME MODE REPLICAS IMAGE
5c1ktgon09lo tartampion_rng replicated 1/1 18092004/dockercoins_rng:1.0
hpy2sg74zidn tartampion_worker replicated 1/1 18092004/dockercoins_worker:1.0
iev0bfpd6pxw tartampion_hasher replicated 1/1 18092004/dockercoins_hasher:1.0
lwyvutx4r9fo tartampion_redis replicated 1/1 redis:latest
zahqsgwpypfm tartampion_webui replicated 1/1 18092004/dockercoins_webui:1.0
root@ird-6-0:~/orchestration-workshop/dockercoins#
# n augmente pas tant que ça en mode swarm avec
root@ird-6-0:~/orchestration-workshop/dockercoins# docker service update tartampion_worker --replicas 10
tartampion_worker
root@ird-6-0:~/orchestration-workshop/dockercoins#
# Global scheduling
# Distribue un service sur chacn des noeud <=> mode replicat
# suppression service
# deployer avec stack
# suppression stack cree qui utlise le port 8080
root@ird-6-0:~/orchestration-workshop/dockercoins# docker stack rm tartampion
Removing service tartampion_rng
Removing service tartampion_worker
Removing service tartampion_hasher
Removing service tartampion_redis
Removing service tartampion_webui
Removing network tartampion_default
root@ird-6-0:~/orchestration-worksho
# ficher dockercompose.yaml
#version qui supporte swarm
version: "3"
services:
rng:
#build: rng
image: 18092004/dockercoins_rng:1.0
ports:
- "8001:80"
deploy:
mode: global ## add
hasher:
#build: hasher
image: 18092004/dockercoins_hasher:1.0
ports:
- "8002:80"
webui:
#build: webui
image: 18092004/dockercoins_webui:1.0
ports:
- "8080:80"
volumes:
- "./webui/files/:/files/"
redis:
image: redis
worker:
#build: worker
image: 18092004/dockercoins_worker:1.0
deploy:
replicas: 10 ### add
# rolling update
root@ird-6-0:~/orchestration-workshop/dockercoins# docker stack deploy -c docker-compose.yml tartampion
Creating network tartampion_default
Creating service tartampion_hasher
Creating service tartampion_webui
Creating service tartampion_redis
Creating service tartampion_worker
Creating service tartampion_rng
root@ird-6-0:~/orchestration-workshop/dockercoins#
root@ird-6-0:~/orchestration-workshop/dockercoins# docker service ls
ID NAME MODE REPLICAS IMAGE
3f8qhj004ky0 tartampion_worker replicated 10/10 18092004/dockercoins_worker:1.0
hlnbcowxsro2 tartampion_hasher replicated 1/1 18092004/dockercoins_hasher:1.0
so7vqd499rw8 tartampion_rng global 3/3 18092004/dockercoins_rng:1.0
uccsjcmekti5 tartampion_redis replicated 1/1 redis:latest
zcj0xiqwpvgt tartampion_webui replicated 0/1 18092004/dockercoins_webui:1.0
root@ird-6-0:~/orchestration-workshop/dockercoins/worker# docker build -t 18092004/dockercoins_worker:1.1 .
Sending build context to Docker daemon 4.608kB
Step 1/5 : FROM python:alpine
---> 02dcd3de5240
Step 2/5 : RUN pip install redis
---> Using cache
---> da689afe436c
Step 3/5 : RUN pip install requests
---> Using cache
---> 94c00bd8c635
Step 4/5 : COPY worker.py /
---> 40a3147bb558
Removing intermediate container 557b2c62309e
Step 5/5 : CMD python worker.py
---> Running in b5cd5182f1c5
---> 44c003645cc6
Removing intermediate container b5cd5182f1c5
Successfully built 44c003645cc6
root@ird-6-0:~/orchestration-workshop/dockercoins/worker# docker push 18092004/dockercoins_worker:1.1
The push refers to a repository [docker.io/18092004/dockercoins_worker]
f21acff3af6a: Pushed
9cd2c92aeb9c: Layer already exists
309a7085dac4: Layer already exists
cf1782ee6739: Layer already exists
3cacaf09fa56: Layer already exists
af4997faab5b: Layer already exists
9f8566ee5135: Layer already exists
1.1: digest: sha256:2f54775be6b3cb45e226493b3b010a6f9af70d1f4246a50a849ed361c78260ff size: 1786
root@ird-6-0:~/orchestration-workshop/dockercoins/worker#
root@ird-6-0:~/orchestration-workshop/dockercoins/worker# docker service update tartampion_worker --image 18092004/dockercoins_worker:1.1
tartampion_worker
root@ird-6-0:~/orchestration-workshop/dockercoins/worker#
root@ird-6-0:~# watch -n1 "docker service ps tartampion_worker | grep -v Shutdown.*Shutdown"
Every 1.0s: docker service ps tartampion_worker | grep -v Shutdown.*Shutdown Fri Apr 28 09:48:51 2017
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR
PORTS
y4t47ja8d3ga tartampion_worker.1 18092004/dockercoins_worker:1.0 ird-6-1 Running Running 13 minutes ago
jw2tftjhanzx tartampion_worker.2 18092004/dockercoins_worker:1.1 ird-6-0 Running Running 5 seconds ago
oiubrrhf8j1l tartampion_worker.3 18092004/dockercoins_worker:1.0 ird-6-2 Running Running 13 minutes ago
qbo72wdcj34u tartampion_worker.4 18092004/dockercoins_worker:1.0 ird-6-0 Running Running 13 minutes ago
x6k60075614c tartampion_worker.5 18092004/dockercoins_worker:1.0 ird-6-1 Running Running 13 minutes ago
i3yewov2upnp tartampion_worker.6 18092004/dockercoins_worker:1.0 ird-6-1 Running Running 13 minutes ago
udgzzgtuwwxy tartampion_worker.7 18092004/dockercoins_worker:1.0 ird-6-1 Running Running 13 minutes ago
7fcuukgu2o18 tartampion_worker.8 18092004/dockercoins_worker:1.1 ird-6-2 Ready Ready 4 seconds ago
fv3sjrjq5prn \_ tartampion_worker.8 18092004/dockercoins_worker:1.0 ird-6-2 Shutdown Running 5 seconds ago
rmj3anoi5gs8 tartampion_worker.9 18092004/dockercoins_worker:1.0 ird-6-0 Running Running 13 minutes ago
oifsm9dlqkrl tartampion_worker.10 18092004/dockercoins_worker:1.0 ird-6-2 Running Running 13 minutes ago
#We can set upgrade parallelism (how many instances to update at the same time)
root@ird-6-0:~/orchestration-workshop/dockercoins/worker# docker service update tartampion_worker --update-parallelism 2 --update-delay 5s
tartampion_worker
root@ird-6-0:~/orchestration-workshop/dockercoins/worker# docker service update tartampion_worker --image 18092004/dockercoins_worker:1.1
tartampion_worker
root@ird-6-0:~/orchestration-workshop/dockercoins/worker# docker service update tartampion_worker --image 18092004/dockercoins_worker:1.0
tartampion_worker
root@ird-6-0:~/orchestration-workshop/dockercoins/worker#
#
0s: docker service ps tartampion_worker | grep -v Shutdown.*Shutdown Fri Apr 28 09:54:24 2017
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR
PORTS
v0hkhx435q46 tartampion_worker.1 18092004/dockercoins_worker:1.0 ird-6-1 Ready Ready 4 seconds ago
rokco55ro3ai \_ tartampion_worker.1 18092004/dockercoins_worker:1.1 ird-6-1 Shutdown Running 4 seconds ago
jw2tftjhanzx tartampion_worker.2 18092004/dockercoins_worker:1.1 ird-6-0 Running Running 5 minutes ago
j67a2oog4apu tartampion_worker.3 18092004/dockercoins_worker:1.0 ird-6-2 Ready Ready 4 seconds ago
xcrmv35vyszg \_ tartampion_worker.3 18092004/dockercoins_worker:1.1 ird-6-2 Shutdown Running 4 seconds ago
47cy710thtnf tartampion_worker.4 18092004/dockercoins_worker:1.1 ird-6-0 Running Running 4 minutes ago
cq5b7ciz14sb tartampion_worker.5 18092004/dockercoins_worker:1.1 ird-6-2 Running Running 3 minutes ago
qxf3yfjq2jj7 tartampion_worker.6 18092004/dockercoins_worker:1.0 ird-6-1 Running Running 9 seconds ago
m0nn1x9qjcol tartampion_worker.7 18092004/dockercoins_worker:1.0 ird-6-1 Running Running 30 seconds ago
7fcuukgu2o18 tartampion_worker.8 18092004/dockercoins_worker:1.1 ird-6-2 Running Running 5 minutes ago
vpijr8jxshhw tartampion_worker.9 18092004/dockercoins_worker:1.0 ird-6-0 Running Running 29 seconds ago
g1dnrq3ui972 tartampion_worker.10 18092004/dockercoins_worker:1.0 ird-6-1 Running Running 9 seconds ago
root@ird-6-0:~/orchestration-workshop/dockercoins/worker# docker stack rm tartampion
Removing service tartampion_worker
Removing service tartampion_hasher
Removing service tartampion_rng
Removing service tartampion_redis
Removing service tartampion_webui
Removing network tartampion_default
root@ird-6-0:~/orchestration-workshop/dockercoins/worker# docker service ls
ID NAME MODE REPLICAS IMAGE
root@ird-6-0:~/orchestration-workshop/dockercoins/worker# docker service create --replicas 4 --name nginx nginx
t2toz04bnxydfzjjhnx4b5o4g
root@ird-6-0:~/orchestration-workshop/dockercoins/worker# docker service ls
ID NAME MODE REPLICAS IMAGE
t2toz04bnxyd nginx replicated 2/4 nginx:latest
root@ird-6-0:~/orchestration-workshop/dockercoins/worker# docker service ls
ID NAME MODE REPLICAS IMAGE
t2toz04bnxyd nginx replicated 4/4 nginx:latest
#container redemare sur un autre noeud qaund on eteint un noeud
Every 2.0s: docker service ps nginx Fri Apr 28 10:08:37 2017
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
iz9ls07xstys nginx.1 nginx:latest ird-6-1 Running Running 2 minutes ago
a01mb8axoxzt nginx.2 nginx:latest ird-6-0 Running Running 2 minutes ago
wz8lb506hfmi nginx.3 nginx:latest ird-6-0 Running Running 8 seconds ago
d1p7wvlin5ng \_ nginx.3 nginx:latest ird-6-2 Shutdown Shutdown 10 seconds ago
4us48bjek8fy nginx.4 nginx:latest ird-6-1 Running Running 2 minutes ago
docker rm node apres avoir demote le node si master
The resource material is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/