docker_practice/image/commit.md

132 lines
7.6 KiB
Go
Raw Permalink Normal View History

# commit
2017-12-20 23:44:09 +08:00
> [](../container)
2017-11-27 14:29:13 +08:00
`docker commit` 使 `docker commit` 使 `Dockerfile`
`docker run` 使 Docker Hub 使
Web
```bash
2017-11-13 18:19:35 +08:00
$ docker run --name webserver -d -p 80:80 nginx
```
`nginx` `webserver` 80 访 `nginx`
Docker访`http://localhost` Docker `localhost`
访 Nginx
![](./_images/images-mac-example-nginx.png)
Docker 使 `docker exec`
```bash
$ docker exec -it webserver bash
root@3729b97e8226:/# echo '<h1>Hello, Docker!</h1>' > /usr/share/nginx/html/index.html
root@3729b97e8226:/# exit
exit
```
`webserver` `bash` Shell
`<h1>Hello, Docker!</h1>` `/usr/share/nginx/html/index.html`
![](./_images/images-create-nginx-docker.png)
`docker diff`
```bash
$ docker diff webserver
C /root
A /root/.bash_history
C /run
C /usr
C /usr/share
C /usr/share/nginx
C /usr/share/nginx/html
C /usr/share/nginx/html/index.html
C /var
C /var/cache
C /var/cache/nginx
A /var/cache/nginx/client_temp
A /var/cache/nginx/fastcgi_temp
A /var/cache/nginx/proxy_temp
A /var/cache/nginx/scgi_temp
A /var/cache/nginx/uwsgi_temp
```
使 Docker `docker commit`
`docker commit`
```bash
docker commit [] <ID> [<>[:<>]]
```
```bash
$ docker commit \
--author "Tao Wang <twang2218@gmail.com>" \
--message "修改了默认网页" \
webserver \
nginx:v2
sha256:07e33465974800ce65751acc279adc6ed2dc5ed4e0838f8b86f0c87aa1795214
```
`--author` `--message` `git`
`docker image ls`
```bash
$ docker image ls nginx
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx v2 07e334659748 9 seconds ago 181.5 MB
nginx 1.11 05a60462f8ba 12 days ago 181.5 MB
2020-02-11 02:03:57 +08:00
nginx latest e43d811ce2f4 4 weeks ago 181.5 MB
```
`docker history` `nginx:latest`
```bash
$ docker history nginx:v2
IMAGE CREATED CREATED BY SIZE COMMENT
07e334659748 54 seconds ago nginx -g daemon off; 95 B
e43d811ce2f4 4 weeks ago /bin/sh -c #(nop) CMD ["nginx" "-g" "daemon 0 B
<missing> 4 weeks ago /bin/sh -c #(nop) EXPOSE 443/tcp 80/tcp 0 B
<missing> 4 weeks ago /bin/sh -c ln -sf /dev/stdout /var/log/nginx/ 22 B
<missing> 4 weeks ago /bin/sh -c apt-key adv --keyserver hkp://pgp. 58.46 MB
<missing> 4 weeks ago /bin/sh -c #(nop) ENV NGINX_VERSION=1.11.5-1 0 B
<missing> 4 weeks ago /bin/sh -c #(nop) MAINTAINER NGINX Docker Ma 0 B
<missing> 4 weeks ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0 B
<missing> 4 weeks ago /bin/sh -c #(nop) ADD file:23aa4f893e3288698c 123 MB
```
```bash
docker run --name web2 -d -p 81:80 nginx:v2
```
`web2` `81` 访 `http://localhost:81` `webserver`
使 `docker commit`
## `docker commit`
使 `docker commit` 使
`docker diff webserver` `/usr/share/nginx/html/index.html`
2019-12-26 11:54:45 +08:00
使 `docker commit` ****使
2017-11-22 20:28:10 +08:00
使使 `docker commit` 西使访