创建一个简单的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