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