docker commit 构建镜像

#当使用docker hub仓库镜像无法满足需求时,则需要定制镜像
1、运行一个nginx1.76.1镜像的容器 web1
docker run --name web1 -d -p 80:80 nginx:1.76.1
#访问可直接看到nginx默认页面


2、进入容器修改首页
docker exec -it web1 bash
echo '<h1>hello Docker nginx 1.16.1 server</h1>' >>/usr/share/nginx/html/index.html
#退出容器,再次访问查看首页内容已变

 
3、查看容器的变化可用 docker diff 容器名
#确定保存构成新的镜像
docker commit --author "felix xie <[email protected]>" --message "更改了默认首页内容" web1 nginx:v1
#查看制作完成的镜像
docker images nginx
docker history nginx:v1    #查看镜像的历史记录

猜你喜欢

转载自www.cnblogs.com/xiefugui/p/12155028.html