怎么理解这个Dockerfile

https://c.163.com/hub#/m/repo...
它在最后启动了那个sshd服务但是在本机我用什么密码链接进去呢?
FROMhub.c.163.com/public/centos:7.2.1511
RUNyumcleanall
RUNyuminstall-yyum-plugin-ovl||true
RUNyuminstall-yvimtarwgetcurlrsyncbzip2iptablestcpdumplesstelnetnet-toolslsofsysstatcroniepython-setuptools
RUNyumcleanall
RUNeasy_installsupervisor
RUNcp-f/usr/share/zoneinfo/Asia/Shanghai/etc/localtime
EXPOSE22
RUNmkdir-p/etc/supervisor/conf.d/
RUN/usr/bin/echo_supervisord_conf>/etc/supervisord.conf
RUNecho[include]>>/etc/supervisord.conf
RUNecho'files=/etc/supervisor/conf.d/*.conf'>>/etc/supervisord.conf
COPYsshd.conf/etc/supervisor/conf.d/sshd.conf
CMD["/usr/bin/supervisord"]
下面是前面centos:7.2.1511的dockerfile文件
FROMscratch
MAINTAINERnetease
ADDcentos-7-docker.tar.xz/
LABELname="CentOSBaseImage"\
vendor="CentOS"\
license="GPLv2"\
build-date="20160701"
ADDCentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo
#安装常用软件
RUNyuminstall-yopenssh-server
#初始化ssh登陆
RUNssh-keygen-trsa-f/etc/ssh/ssh_host_rsa_key-N''
RUNssh-keygen-tdsa-f/etc/ssh/ssh_host_dsa_key-N''
RUNssh-keygen-tecdsa-f/etc/ssh/ssh_host_ecdsa_key-N''
RUNssh-keygen-ted25519-f/etc/ssh/ssh_host_ed25519_key-N''
RUNecho"RSAAuthenticationyes">>/etc/ssh/sshd_config
RUNecho"PubkeyAuthenticationyes">>/etc/ssh/sshd_config
RUNyumcleanall
#启动sshd服务并且暴露22端口
RUNmkdir/var/run/sshd
EXPOSE22
CMD["/usr/sbin/sshd","-D"]
LEATH
浏览 441回答 2
2回答

Qyouu

首先,吐槽一下,这个Dockerfile写的真没什么值得学习的,一点不符合最佳实践,一行命令用一个RUN。。。如果不用dockerexec的方式登录的话,用ssh跟正常的centos没区别,自己建立公钥私钥就行了。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript