在docker中部署centos7鏡像

本篇文章參考自:html

http://www.javashuo.com/article/p-cmfybrli-kz.htmlpython

http://www.javashuo.com/article/p-frpojmlo-en.htmldocker

一、安裝Docker for Windows,點擊https://store.docker.com/editions/community/docker-ce-desktop-windows進入下載vim

二、創建centos7鏡像庫,可到網易蜂巢選擇一份Dockerfile複製,網址爲 https://c.163yun.com/hub#/m/repository/?repoId=1055windows

三、將複製的內容放到新建的Dockerfile文件中,這個文件須要本身建立,但注意這個文件不要加上後綴centos

這裏我複製的內容爲:bash

FROM hub.c.163.com/public/centos:7.2.1511
RUN yum clean all
RUN yum install -y yum-plugin-ovl || true
RUN yum install -y vim tar wget curl rsync bzip2 iptables tcpdump less telnet net-tools lsof sysstat cronie python-setuptools
RUN yum clean all
RUN easy_install supervisor
RUN cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
EXPOSE 22
RUN mkdir -p /etc/supervisor/conf.d/
RUN /usr/bin/echo_supervisord_conf > /etc/supervisord.conf
RUN echo [include] >> /etc/supervisord.conf
RUN echo 'files = /etc/supervisor/conf.d/*.conf' >> /etc/supervisord.conf
COPY sshd.conf /etc/supervisor/conf.d/sshd.conf
CMD ["/usr/bin/supervisord"]

四、建立一個文件夾,將Dockerfile文件放到文件夾下,使用cmd打開命令行,切換到Dockerfile文件,執行下面的程序:less

docker build -t docker-whale . 

(注意這裏有一個點,不要忘記了)ssh

五、等待Dockerfile裏面的腳本執行吧,執行結束後,在命令行中輸入docker images就能夠查看到新配的centos7鏡像了curl

六、在控制檯中輸入docker run -ti <鏡像ID> /bin/bash,便可進入centos7操做系統了

相關文章
相關標籤/搜索