FROM ubuntu:latest RUN apt update && apt install openssh-server sudo -y RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 test RUN echo 'test:test' | chpasswd RUN service ssh start EXPOSE 22 CMD ["/usr/sbin/sshd","-D"]构建镜像
docker build -t IMAGE_NAME .启动容器
docker run IMAGE_NAME -p 2222:22SSH测试
ssh test@ip_address -p 2222参考:
- How to setup an ssh server within a docker container
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)