文章目录
使用Dockerfile制作基于Centos7的Nginx应用镜像 创建Dockerfile 创建镜像 上传镜像-harbor 修改hosts文件 修改daemon.json 重启DOCKER 登录并上传 测试镜像
使用Dockerfile制作基于Centos7的Nginx应用镜像
创建Dockerfile
FROM centos:7
MAINTAINER "WWW"
RUN yum install -y http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.24.0-1.el7.ngx.x86_64.rpm
COPY dest/index.html /usr/share/nginx/html/
EXPOSE 80/tcp
ENTRYPOINT ["nginx", "-g", "daemon off;"]
创建镜像
[ root@docker nginx]
/root/dockerfile/
└── nginx
├── dest
│ └── index.html
└── Dockerfile
[ root@docker nginx]
[ root@docker nginx]
REPOSITORY TAG IMAGE ID CREATED SIZE
centos v1.1 90714e48dcba 2 minutes ago 431MB
上传镜像-harbor
修改hosts文件
[ root@docker nginx]
127.0 .0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168 .110.139 www.kvm.cn
修改daemon.json
{
"registry-mirrors" : [ "https://hnjwpdu9.mirror.aliyuncs.com" ] ,
"insecure-registries" : [ "www.kvm.cn" ]
}
重启DOCKER
[ root@docker nginx]
登录并上传
[ root@docker nginx]
Username: admin
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/
Login Succeeded
[ root@docker nginx]
The push refers to repository [ www.kvm.cn/library/centos7]
125496b805c2: Pushed
5efa92506a53: Pushed
174f56854903: Pushed
v1.1: digest: sha256:8cef5e2c8b505441ed50380961288c4f82d727cb34f0590bd2f2ebad6e820c25 size: 948
测试镜像
[ root@docker nginx]
8220d8c238c1d865fd896fc66b972d3394fd84fff3b887424021c5de45345cac
[ root@docker nginx]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8220d8c238c1 www.kvm.cn/library/centos7:v1.1 "nginx -g 'daemon of…" 5 seconds ago Up 5 seconds 80 /tcp centos7v1.1
[ root@docker nginx]
[ root@8220d8c238c1 /]
Nginx Web Test
[ root@docker nginx]
Nginx Web Test