- 拉取镜像
docker pull daocloud.io/nginx
- 本地(运行docker的机器)存一份nginx配置
server {
root /ext/jingzhao/;
listen 8000;
access_log /ext/jingzhao/access.log;
error_log /ext/jingzhao/error.log;
client_max_body_size 50M;
sendfile on;
tcp_nopush on;
set $project /ext/jingzhao/;
charset utf-8;
location / {
root $project/;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /40x.html {
root html;
}
}
- 创建一份DOCFILE文件
FROM daocloud.io/nginx
MAINTAINER jingzhao jingzhao5@iflytek.com
COPY cc.conf /etc/nginx/conf.d/nginx.conf
COPY dist/ /ext/jingzhao
EXPOSE 80 443 8000
CMD ["nginx", "-g", "daemon off;"]
4.运行 docker build -t xxx .
5.查看刚刚建立的镜像 docker images
6.容器跑起来 docker run --name xxx-nginx -p 19998:8000 -d xxx:v1.0.0
7.检查刚刚建立的容器状态 docker ps -a
8.如果7有问题(status没有正常运行),则(记得kill掉之前创建失败的容器)
docker run -ti -p 19998:8000 xxx /bin/bash
nginx -g "daemon off;"
检查容器里的报错情况,再根据具体情况修改config或者docfile
如果没问题 访问 localhost:19998
就大功告成了
接下来就是push镜像到仓库的过程
1.登录 docker login [IP]
2.查看刚才创建镜像的ID docker images
3.打tag docker tag [image ID] xxx
4.最后 docker push xxx