創建一個簡單的Docker鏡像


1. 創建 Dockerfile 文件、index.html測試頁面

[root@localhost docker]# vi Dockerfile

FROM nginx:1.17.6  #基於 nginx 1.17,在build 時,會自動pull 一個 1.17.6 版本的 nginx

ENV LANG en_US.UTF-8 #設置環境變量

ADD index.html /usr/share/nginx/html  將本地的index.html添加到鏡像中

EXPOSE 80  #開放 80 端口
EXPOSE 443 #開放 443 端口

[root@localhost docker]# vi index.html
Hello K8S

 

 編譯 docker

[root@localhost docker]# docker build . -t hello-k8s:0.0.1

 

  run docker 鏡像

[root@localhost docker]# docker run -d --name hello7001 -p 7001:80 hello-k8s:0.0.1

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM