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

 

猜你喜欢

转载自www.cnblogs.com/vipsoft/p/12587031.html