dockerfile create a mirror file description, each parameter

dockerfile create a mirror file description, each parameter

Workdir the root role as a command execution

enter description here
enter description here

cmd entrypoint and relations, as well as restrictions cmd can only last in effect

enter description here
enter description here

How ssh connection a container, practice

dockerfile

# 指定基础镜像 FROM ubuntu:14.04 # 安装软件 RUN apt-get update && apt-get install -y openssh-server && mkdir /var/run/sshd # 添加用户 shiyanlou 及设定密码 RUN useradd -g root -G sudo shiyanlou && echo "shiyanlou:123456" | chpasswd shiyanlou EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"]

<Font style = "color:" red ""> Construction of tests are as follows

First of all, before we created an empty directory dir1 edit Dockerfile file and copy the contents of the above to the file, the associated command is as follows:

Create a directory

$ mkdir dir1 && cd dir1

Edit Dockerfile, write the contents of the above

$ vim Dockerfile

Finally, execute build command

The sshd -t Docker Build $:. Test
Copy
After the above command is completed, the image constructed on successful, a boot image used directly vessel can run a ssh service, as follows:

RUN -itd Docker -p 10001 $: 22 is the sshd: Test
Copy
this case can the public network IP address, and port 10001, and the user shiyanlou, 123456, remotely connected to the container through the ssh.

Guess you like

Origin www.cnblogs.com/miaozhijuan/p/12657132.html