- 使用dockerfile创建docker镜像
配置某个dockerfile文件时,需要自己动手在容器在容器中操作一遍,随后在dockerfile中复现该过程即可,对于一些需要交互的场景,可以使用管道,比如passwd --stdin# dockfile build ssh server from centos # base image FROM centos # maintainer information MAINTAINER xiaozhifc 1786614260@qq.com # install package needed RUN yum update -y RUN yum install --nogpgcheck openssh-server net-tools -y # shutdown the pam authentication RUN sed -i 's/session required pam_loginuid.so/#session required pam_loginuid.so/g' /etc/pam.d/sshd # generate the necessary certificates RUN sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/g' /etc/ssh/sshd_config RUN sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config RUN ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N "" RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N "" RUN ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" # change the linux root password RUN echo 'wodemima' | passwd --stdin root EXPOSE 22 # print the ip addr of container and start the sshd service CMD ifconfig eth0 | grep netmask | awk '{print $2}'; /usr/sbin/sshd -D
网友评论