docker发布镜像

2019-12-24  本文已影响0人  一碗米粉的故事

https://hub.docker.com

有一篇教程 :https://blog.csdn.net/u011541946/article/category/8605832

windows平台操作:

安装nginx镜像

docker pull nginx

在你需要的有文件的地方(比如index.html,请随意)
建立一个 Dockerfile 文件
文件内容:
FROM nginx:latest
COPY index.html /usr/share/nginx/html/

好了 准备开始创建自己的镜像了
在Dockerfile的目录下执行(命令行后有个小点,一定加上)
docker build -t hello-html .

完成后:
在docker images 一下,你就能看到自己创建的镜像了。

然后执行命令创建容器:
docker run -d --name hello -p 8848:80 hello-html

或者 docker run -d -p 8848:80 hello-html

打开浏览器 输入 :http://localhost:8848 就可以看到index.html里的内容了

如果文件有改动 再执行build 重新启动
docker build -t hello-html .

如果提示端口号被占用

先执行docker ps 把正在跑的服务stop
docker stop copy的哪个容器ID

需要发布镜像需先登陆
输入 docker login
会提示 Login Succeeded

要发布必须执行 1990dk 是你的dockerid,如果不是这样,就目前建立的hello-html容器发布会发生错误:denied: requested access to the resource is denied

docker tag hello-html 1990dk/hello-html

执行完命令可以去dockerhub上看到自己的镜像了

END

上一篇 下一篇

猜你喜欢

热点阅读