Docker ubuntu ssh 컨테이너
% podman build -t my-ubuntu:latest .
#FROM docker.io/library/ubuntu:latest #FROM docker.io/library/debian:latest FROM docker.io/library/ubuntu:20.04 MAINTAINER Seoul # Environment USER root ENV LANG=ko_KR.utf8 TZ=Asia/Seoul ENV DEBIAN_FRONTEND noninteractive # PKG Install for Ubuntu RUN apt-get update RUN apt-get install -y openssh-server aptitude net-tools curl wget lrzsz iputils-ping iproute2 ssh stress # Configuration SSHD RUN mkdir /var/run/sshd RUN sed -i "/^[^#]*UsePAM/ s/.*/#&/" /etc/ssh/sshd_config RUN echo "UsePAM no" >> /etc/ssh/sshd_config RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config # Changing Root passwd RUN echo 'root:1234qwer' | chpasswd # SSH PORT CONFIGUATION EXPOSE 22 # RUNNING SSH CMD /usr/sbin/sshd -D |
% podman run -d -P --name ubuntu_20.40_SSH my-ubuntu:latest
% podman exec -it ubuntu_20.40_SSH /bin/bash
% podman stop ubuntu_20.40_SSH
% podman rm ubuntu_20.40_SSH
컨테이너 SSH 실행
$ podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 889e4b90004a localhost/my-ubuntu:19.04 /bin/sh -c /usr/s... About a minute ago Up About a minute ago 0.0.0.0:41833->22/tcp ubuntu_20.40_LTS_SSHD $ ssh localhost -p 41833 The authenticity of host '[localhost]:41833 ([127.0.0.1]:41833)' can't be established. ECDSA key fingerprint is SHA256:IsUc6J+i88JUcIYUfJFXbT2OV+/U9MT7UMpp8nHb5oE. ECDSA key fingerprint is MD5:23:2d:d9:8e:0d:be:c0:48:17:f5:84:f1:74:f2:3e:be. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '[localhost]:41833' (ECDSA) to the list of known hosts. root@localhost's password: Last login: Sun Mar 6 13:45:47 2022 from ::1 root@889e4b90004a:~# |
[PODMAN으로 rm 시에 cannot remove container 에러 발생 시]
% podman stop ubuntu_20.40_LTS_SSHD
% podman rm ubuntu_20.40_LTS_SSHD
Error: cannot remove container 803215827b12f7548da1ebd05 as it has active exec sessions: container state improper
이와 같은 에러가 발생할 경우에는 아래와 같이 podman을 해당 컨테이너에 대해서 restart를 진행하면 그 이후에 rm이 진행 됩니다.
% podman restart ubuntu_20.40_LTS_SSHD
% podman rm ubuntu_20.40_LTS_SSHD
컨테이너 빌드/실행
# CONTAINER BUILD
# % podman build -t my-ubuntu:latest .
# % podman build -t my-ubuntu:20.04 .
# % podman build -t my-ubuntu:19.04 .
# % podman build -t my-ubuntu:12.04 .
# % podman build -t my-ubuntu .
# % podman build --rm -t my-ubuntu .
# % podman run -d -P --name ubuntu_latest_SSH my-ubuntu:latest
# % podman run -d -P --name ubuntu_20.40_SSH my-ubuntu:20.40
# % podman run -d -P --name ubuntu_19.04_SSH my-ubuntu:19.04
# % podman exec -it ubuntu_20.40_SSH /bin/bash
# % podman exec -it ubuntu_19.04_SSH /bin/bash
#
# % docker build --rm -t sshd .
# % docker run -d -P --name ubuntu_12.04_LTS_SSHD sshd
# % docker run -it --entrypoint "/bin/bash" ubuntu:20.04
# % sudo docker run --privileged hello-world
#