docker 创建镜像有两种方式:一种是docker commit 指令,一种是通过docker build 和 Dockerfile
今天在这里给大家介绍如何通过 docker build 和 Dockerfile来创建 ssh 镜像
以下操作环境是:Ubuntu-16.04-server版,用户是 root
1.我们在daocloud上pull一个基础镜像下来:
# docker pull daocloud.io/library/ubuntu:14.04
2.我们创建一个目录 /home/ssh
# mkdir -p /home/ssh
3.我们进入 ssh 目录
# cd /home/ssh
4.创建 Dockerfile文件
# touch Dockerfile
5.编辑Dockerfile文件
# vim Dockerfile
内容如下:
FROM daocloud.io/library/ubuntu:14.04
RUN apt-get update -y
RUN apt-get install -y openssh-server openssh-client
RUN useradd -r ldy #创建一个名为 ldy 的用户
RUN echo "ldy:ldy123" | chpasswd #给 ldy 用户设置一个密码为 ldy123
RUN echo "ldy ALL=(ALL) ALL" >&