Dockerfile構建本地鏡像

來源:互聯網
上載者:User
首先先建立一個centos容器 #docker create centos:cenos6
刪除一個容器。 a005304e4e74 (鏡像Id) -f 參數是強制移除,有時有依賴會無法刪除 docker rmi  -f  a005304e4e74 
查看當前容器: docker images
如果有如下資訊:則建立鏡像成功 centos              centos6             a005304e4e74        10 weeks ago        203.1 MB
進入容器:

#docker run -t -i centos:centos6


建立一個目錄   (如果成功則顯示如下的終端顯示,061a24a8acca這個是容器的id)  [root@061a24a8acca /]# mkdir ssh 
退出容器 [root@061a24a8acca /]#exit
使用commit命令提交到本地本地庫中,-m是建立的images的資訊,--author指定作者,xixihe/xxoo分別是倉庫名和鏡像名,v1是TAG名 #docker commit  -m="Message" --author="xixihe" 061a24a8acca xixihe/xxoo:v1
然後進入容器再次查看 #docker run -t -i xixihe/xxoo:v1
查看建立目錄,在則成功,不在則失敗 [root@061a24a8acca /]# ls
使用dockerfile建立鏡像 #vim /root/Dockfile FROM xixihe/sqlite3:v1 USER root RUN yum -y install lrzsz RUN touch test.txt && echo "asfalf" > abc.txt ENV WEBAPP_PORT=9090 WORKDIR /opt/ ENTRYPOINT ["ls"] CMD ["-a", "-1"] VOLUME ["/data","/var/www"] ONBUILD ADD . /app/src ONBUILD RUN echo "on build excuted" >> onbuild.txt
構建鏡像,不要忽略後面的 .     . 代表當前dockerfile當前路徑。即dockerfile路徑是pwd   /root/Dockerfile #docker build -t xixihe/test:v1 .
查看鏡像,是否成功 docker images


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.