1. 完成本地 hub 的搭建,并截图。
- 适用docker pull 拉取registry镜像
- 启动容器,创建本地hub
root@VM-16-5-ubuntu:~# docker run -d -p 5000:5000 -v ./myregistry/local/registry:/var/lib/registry --restart=always --name registry registry:2
9f36d4b3fdd94cdc49074375738b6a0ea4f935462e80c9ca4c009368126d29db
2. 不使用挂载的方式,而是通过 Docker 制作的方式实现对 Nginx 的默认页的修改,把制作的 Dockerfile 和首页 html 传到代码仓。
root@VM-16-5-ubuntu:~/mydockerfile# cat Dockerfile
FROM nginx:latest
COPY index.html /usr/share/nginx/html/
root@VM-16-5-ubuntu:~/mydockerfile# cat index.html
<html>
<head>
<meta charset="UTF8">
<title>NGINX</title>
</head>
<h1>hello world,这是一个本地构建的NGINX服务</h1>
</html>
- 3 适用docker build 生成镜像
- 4 启动容器
- 5 访问容器地址,展示nginx内容
3. 推送自己定制好的 Nginx 镜像到本地镜像仓库 hub 中,查询本地镜像仓库中的镜像截图。
- 打标签,确定要推送的镜像标签
docker tag nginx:v2 localhost:5000/nginx:pushone
- 推送Docker镜像到指定仓库
docker push localhost:5000/nginx:pushone
- 查看镜像仓库包含的镜像 curl http://localhost:5000/v2/_catalog
4. 从本地仓库拉取定制好的 Nginx 镜像,启动该 Nginx 访问并截图 。
root@VM-16-5-ubuntu:~# docker pull localhost:5000/nginx:pushone
pushone: Pulling from nginx
Digest: sha256:848b3d96f54dacb67704742e4f067dad6976e57d1f203100ab9b415ec0e076f3
Status: Image is up to date for localhost:5000/nginx:pushone
localhost:5000/nginx:pushone
root@VM-16-5-ubuntu:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost:5000/nginx pushone 90002c293a6e 3 hours ago 187MB