docker Dockerfile创建docker镜像
程序员文章站
2024-03-12 11:22:02
...
创建一个目录
mkdir docker
创建并编辑Dockerfile
vi Dockerfile
#Dockerfile
#基于centos6镜像创建,本地存在的镜像将会覆盖网络上的镜像镜像构建
FROM centos:centos6
MAINTAINER colin <[email protected]>
#update yum repository and install openssh server
RUN yum update -y
RUN yum install -y openssh-server
#generate ssh key
RUN ssh-****** -q -N "" -t dsa -f /etc/ssh/ssh_host_dsa_key
RUN ssh-****** -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key
RUN sed -ri 's/session required pam_loginuid.so/#session required pam_loginuid.so/g' /etc/pam.d/sshd
RUN mkdir -p /root/.ssh && chown root.root /root && chmod 700 /root/.ssh
#change root password to 123456
RUN echo 'root:123456' | chpasswd
#RUN curl https://git.oschina.net/feedao/Docker_shell/raw/start/ali-centos.sh | sh
#ENV LANG en_US.UTF-8
#ENV LC_ALL en_US.UTF-8
#supervisord服务管理工具,主要用于docker多服务器启动
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
RUN yum -y install supervisor
COPY supervisord.conf /etc/supervisord.conf
#运行时需要使用-p指定端口
EXPOSE 22
CMD /usr/sbin/sshd -D
#End
创建镜像
docker build -t docker_container .
转载于:https://my.oschina.net/colin86/blog/2876464