“Docker" First Try (4)

My Stuided Log.

＜Today's topic : Try to use "Baseimage-docker"＞
■What's Baseimage-docker?
baseimage-docker has several specification as below,
1. Ubuntu base image
2. Have init prosess as default, and cron & syslog will start automatically
3. Easily manage several services by hypervisor
4. be able to use this via SSH

(1)login to EC2,then start docker deamon.

```
$sudo systemctl start docker
$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
```


(2)download Baseimage from repository ,then RUN

```
$ docker pull phusion/baseimage:0.11
0.11: Pulling from phusion/baseimage
c64513b74145: Pull complete 
01b8b12bad90: Pull complete 
c5d85cf7a05f: Pull complete 
b6b268720157: Pull complete 
e12192999ff1: Pull complete 
d39ece66b667: Pull complete 
65599be66378: Pull complete 
Digest: sha256:6ba22a31a809de669243b79f982f7b2df733ead1ec45becff401b4d5d79150bb
Status: Downloaded newer image for phusion/baseimage:0.11

$ docker images -a
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
phusion/baseimage         0.11                14e6c478b00a        11 months ago       183MB

$ docker run
"docker run" requires at least 1 argument.
See 'docker run --help'.

Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container
$ docker run phusion/baseimage:0.11
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/10_syslog-ng.init...
Aug  7 16:40:26 fdedc246d871 syslog-ng[13]: syslog-ng starting up; version='3.13.2'
*** Booting runit daemon...
*** Runit started as PID 21
Aug  7 16:40:27 fdedc246d871 cron[24]: (CRON) INFO (pidfile fd = 3)
Aug  7 16:40:27 fdedc246d871 cron[24]: (CRON) INFO (Running @reboot jobs)

#Exit via Ctrl+C
^C*** Shutting down runit daemon (PID 21)...
*** Running /etc/my_init.post_shutdown.d/10_syslog-ng.shutdown...
Aug  7 16:41:24 fdedc246d871 syslog-ng[13]: syslog-ng shutting down; version='3.13.2'
*** Init system aborted.
*** Killing all processes...

```

■Who is Baseimage's hypervisor?
"Runit" is managing Baseimage-docker's service as hypervisor.
Runit is able to control Container's service.Let's try this as below.

```
#Run baseimage-docker
$ docker run -it phusion/baseimage:0.11 /sbin/my_init -- bash -l
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/10_syslog-ng.init...
Aug  7 16:47:49 ef3141a8d76d syslog-ng[13]: syslog-ng starting up; version='3.13.2'
*** Booting runit daemon...
*** Runit started as PID 21
*** Running bash -l...
Aug  7 16:47:50 ef3141a8d76d cron[27]: (CRON) INFO (pidfile fd = 3)
Aug  7 16:47:50 ef3141a8d76d cron[27]: (CRON) INFO (Running @reboot jobs)

#Now I could type from prompt, try to check current process
root@ef3141a8d76d:/# ps axwf
  PID TTY      STAT   TIME COMMAND
    1 pts/0    Ss     0:00 /usr/bin/python3 -u /sbin/my_init -- bash -l
   13 pts/0    Sl     0:00 /usr/sbin/syslog-ng --pidfile /var/run/syslog-ng.pid -F --no-caps
   21 pts/0    S      0:00 /usr/bin/runsvdir -P /etc/service
   23 ?        Ss     0:00  \_ runsv cron
   27 ?        S      0:00  |   \_ /usr/sbin/cron -f
   24 ?        Ss     0:00  \_ runsv sshd
   22 pts/0    S      0:00 bash -l
   36 pts/0    R+     0:00  \_ ps axwf

#runsvdir is main supervisor.

root@ef3141a8d76d:/# 
root@ef3141a8d76d:/# sv status cron sshd
run: cron: (pid 27) 20s
down: sshd: 20s
#cron is now executing pid:27, could confirm sshd was downstatus fro 20s.