supervisor + ssh 데비안 도커 이미지 빌드

1 개요[ | ]

supervisor + ssh 데비안 도커 이미지 빌드 만들기

2 Dockerfile 작성[ | ]

vi Dockerfile
FROM debian:10-slim
RUN set -x \
&& apt-get update -y \
&& apt-get install -y --no-install-recommends \
  supervisor \
  openssh-server \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir /var/run/sshd \
&& echo 'root:P@ssw0rd' | chpasswd \
&& sed 's/#PermitRootLogin.*/PermitRootLogin yes/g' -i /etc/ssh/sshd_config \
&& mkdir -p /var/log/supervisor \
&& echo "[program:sshd]\n\
command=/usr/sbin/sshd -D" > /etc/supervisor/conf.d/supervisord.conf
EXPOSE 22
CMD ["/usr/bin/supervisord","-n"]

3 docker build[ | ]

$ docker build -t debian_supervisor_ssh .
Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM debian:10-slim
10-slim: Pulling from library/debian
c499e6d256d6: Pull complete 
Digest: sha256:76c15066d7db315b42dc247b6d439779d2c6466f7dc2a47c2728220e288fc680
Status: Downloaded newer image for debian:10-slim
 ---> 8e022c70c28b
Step 2/4 : RUN set -x && apt-get update -y && apt-get install -y --no-install-recommends   supervisor   openssh-server && rm -rf /var/lib/apt/lists/* && mkdir /var/run/sshd && echo 'root:P@ssw0rd' | chpasswd && sed 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' -i /etc/ssh/sshd_config && mkdir -p /var/log/supervisor && echo "[program:sshd]\ncommand=/usr/sbin/sshd -D" > /etc/supervisor/conf.d/supervisord.conf
 ---> Running in 1ba732bfe751
+ apt-get update -y
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [122 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
... (생략)
+ echo [program:sshd]\ncommand=/usr/sbin/sshd -D
Removing intermediate container 1ba732bfe751
 ---> 98eaa9392f87
Step 3/4 : EXPOSE 22
 ---> Running in 69aaaabaf9ef
Removing intermediate container 69aaaabaf9ef
 ---> 7dc01dd3a2d2
Step 4/4 : CMD ["/usr/bin/supervisord","-n"]
 ---> Running in e41ae580938d
Removing intermediate container e41ae580938d
 ---> 2a2f269738b3
Successfully built 2a2f269738b3
Successfully tagged debian_supervisor_ssh:latest

4 docker run[ | ]

$ docker run -d -P --name my_container debian_supervisor_ssh
456382b756f4a15bf212cf3c7046047cbd1856829814d00504ddfb20dd04daef
$ docker ps
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                   NAMES
456382b756f4        debian_supervisor_ssh   "/usr/bin/supervisor…"   12 seconds ago      Up 12 seconds       0.0.0.0:32769->22/tcp   my_container

5 테스트[ | ]

$ ssh root@localhost -p 32769
The authenticity of host '[localhost]:32769 ([127.0.0.1]:32769)' can't be established.
ECDSA key fingerprint is SHA256:HUtGEi3M8soXDDMZuZAmCdO6Ydbo1L+a3KD484KRr8E.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[localhost]:32769' (ECDSA) to the list of known hosts.
root@localhost's password: P@ssw0rd
Linux 456382b756f4 4.19.112+ #1 SMP Thu Mar 26 23:42:41 PDT 2020 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@456382b756f4:~# ps -ef
UID          PID    PPID  C STIME TTY          TIME CMD
root           1       0  0 14:21 ?        00:00:00 /usr/bin/python2 /usr/bin/supervisord -n
root           8       1  0 14:21 ?        00:00:00 /usr/sbin/sshd -D
root           9       8  0 14:21 ?        00:00:00 sshd: root@pts/0
root          15       9  0 14:21 pts/0    00:00:00 -bash
root          18      15  0 14:22 pts/0    00:00:00 ps -ef
root@456382b756f4:~# exit
logout
Connection to localhost closed.
$


6 같이 보기[ | ]

7 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}