I build an docker image using a Dockerfile. After building the image, I made some basic changes on the Dockerfile. Is it possible to rebuild the same image with just the additional changes. Since, it takes very long time to create the image, I don't want to build it completely. Thanks in advance.
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
Yes, if you tag your docker image myimage, just start your other Dockerfile with
FROM myimage
and put after this your additional changes
All docker build work in the way, that you describe.
The only thing need to be taken into account is layer dependencies.
Consider Dockerfile
If you change
cmd1
then all layers will be rebuilt, because they could be different with respect tocmd1
If you change
cmd4
than only this command will be rebuilt, because it has not affect any other layers.Think about what commands need to be run in what order - maybe you can improve it by reordering the statements.
You can't rebuild it with the changes, you would need to store persistent data on a volume for that.
To save your changes,however, you can use
commit
:https://docs.docker.com/engine/reference/commandline/commit/
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]