用Dockerfile封装docker镜像的(封装服务)
docker镜像的封装(httpd服务)编写yum文件cd /tmp/doctervim dvd.repo[dvd-rhel]name=dvd-rhelbaseurl=http://172.25.11.250/rhel7.3gpgcheck=0编写镜像文件vim DockerfileFROM rhel7ENV HOSTNAME server1MAINTAIN...
·
docker镜像的封装(httpd服务)
编写yum文件
cd /tmp/docter
vim dvd.repo
[dvd-rhel]
name=dvd-rhel
baseurl=http://172.25.11.250/rhel7.3
gpgcheck=0
编写镜像文件
vim Dockerfile
FROM rhel7
ENV HOSTNAME server1
MAINTAINER redhat@westos.org
EXPOSE 80
COPY dvd.repo /etc/yum.repos.d/dvd.repo
RUN rpmdb --rebuilddb && yum install -y httpd && yum clean all
VOLUME ["/var/www/html"]
CMD ["/usr/sbin/httpd","-D","FOREGROUND"]
docker build -t rhel7:v1 .
成功
docker images rhel7
docker run -d --name vm4 -v /tmp/docker/web/:/var/www/html rhel7:v1
docker镜像的封装(sshd服务)
编写yum文件
cd /tmp/docker/
mkdir ssh/
vim dvd.repo
[dvd-rhel]
name=dvd-rhel
baseurl=http://172.25.11.250/rhel7.3
gpgcheck=0
编写镜像文件
vim Dockerfile
FROM rhel7
ENV HOSTNAME server2
MAINTAINER redhat@westos.org
EXPOSE 22
COPY dvd.repo /etc/yum.repos.d/dvd.repo
RUN rpmdb --rebuilddb && yum install -y openssh-server openssh-clients && yum clean all && ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -N "" && ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N "" && ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ed25519_key -N "" && echo root:redhat | chpasswd
CMD ["/usr/sbin/sshd","-D"]
docker build -t rhel7:v2 .
docker run -d --name vm5 rhel7:v2
ssh 172.17.0.6
更多推荐
已为社区贡献5条内容
所有评论(0)