首先我们在磁盘下新建一个static_web的目录,并且新建一个dockerfile的文件

并在里面构建如下代码
#author:test
#date:1,1
#version:1.1
FROM ubuntu:latest
MAINTAINER ma1ware "test@test.com"
RUN apt-get update && apt-get install -y nginx
RUN echo 'This is a container test' >/usr/share/nginx/html/index.html
EXPOSE 80
然后
sudo docker build -t="test/ubuntu:latest" PATH
(path是你自己文件的路径)

这样build命令便会按照step去执行,最终完成构建。

然后我们基于新构建的镜像启动一个容器
sudo docker run -d -p 80 --name static_web ma1ware/static_web nginx -g "daemon off;"

然后我们检查端口转发是否正常

ok ,正常工作
然后我们连接本地做个测试

使用
sudo docker push 用户名/文件名
就可以上传镜像到hub了。

网友评论