1,进入容器修改内容,下面是容器的一个结构图
2, 进入docker控制台 /bin/bash或者/bin/sh
docker exec -it 0362fa169399 /bin/bash
,3,查看nginx 首页index.html,通过修改这个首页html可以修改首页的静态内容
修改之前首页
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
修改之后首页
echo "<h1>welcome to atguigu</h1>" > index.html
4,提交改变
我们先退出docker容器内部exit
docker commit --help
Options:
-a, --author string Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")
-c, --change list Apply Dockerfile instruction to the created image
-m, --message string Commit message
-p, --pause Pause container during commit (default true)
docker commit -a 'yuwenlong' -m '首页变化' 0362fa169399 wenlongNginx:v1.0
docker commit -a 'yuwenlong' -m '首页变化' 0362fa169399 wenlongnginx:v1.0
使用了一个大写字母报了一个错:invalid reference format: repository name must be lowercase
docker images可以看到我刚才提交的新镜像
设置项没有设置名字,docker默认会给你生成一个名字
使用你提交镜像改变文件依然可以启动访问 ,这是一个重要的特性