How does docker run -t -i /bin/bash save the changes?

  docker, question

I want to modify the contents of the container through docker’s /bin/bash and commit the new image.

The unsuccessful operation process is as follows:

docker run -t -i docker-wordpress-nginx /bin/bash

Enter container bash

vi /etc/nginx/sites-available/default

Nginx’s conf file was modified.


Exit the container and run

docker ps

Nothing. run

docker images

Still the original images.

Can you tell me how to save the changes bash made in docker and how to commit?

PS1: How to commit to automatically tag a new image and invalidate the previous template?

PS2: If you get three versions of tag v1, v2, v3 and v3 through modification and commit, can you delete V1 and V2 and keep V3? Is there an association (stacking) relationship between individual images?

docker commit --help

A1. if A1. commit does not add a tag, it defaults to the latest. if it is modified on the latest image and then committed does not add a tag, it will replace the original latest. generally, the original latest image will be tagged before committing.

A2. v1, v2 and v3 are all tags you added yourself.docker rmi username/repo:v1You can delete itv1This tag does not affect other tags.

At the same time, if v1, v2 and v3 tags are typed on the same image id, they are deletedv1Tag will not delete the corresponding image