dnf remove -y podman buildah
dnf config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo
dnf install -y docker-ce docker-ce-cli containerd.io
systemctl enable –now docker
vim Dockerfile
FROM fros/centos9
RUN dnf install -y openssh-server openssh-clients iproute net-tools hostname passwd && \
dnf clean all && \
mkdir -p /var/run/sshd && \
echo “root:root” | chpasswd && \
sed -i ‘s/#PermitRootLogin yes/PermitRootLogin yes/’ /etc/ssh/sshd_config && \
sed -i ‘s/PasswordAuthentication no/PasswordAuthentication yes/’ /etc/ssh/sshd_config
EXPOSE 22
CMD [“/usr/sbin/sshd”, “-D”]
docker build -t centos9-ssh .
docker network create net1
docker network create net2
docker run -dit –name c1 –network net1 centos9-ssh
docker run -dit –name c2 –network net2 centos9-ssh
docker network connect net2 c1
docker exec -it c1 bash
echo “This is a test file” > /root/testfile.txt
scp /root/testfile.txt root@:/root/