How does Docker skip installing official images locally?

  docker, question

I downloaded a MySql image locally and want to install the official one.
docker pull mysqlAfter that, it always automatically installed the local ones.

Delete local mysqldocker rmi -f mysql
docker imagesThe check is gone, but
Againdocker pull mysql, found that the installation is still the previous …

How to skip the local MySql and install the official image? Thank you

Is there any container using this mysql image? Or do you want to start overdocker tagThrough this mirror image? Or use other versions of mysql images? Or in the use ofdebian:jessieA mirror image of?

It is important to know that mirroring is not a single file, but a collection of storage tiers. When you executedocker rmi -f mysqlWhen, in fact, is deletedmysql:latestThis ..tagSo the first line is generallyUntagged: mysql:latest.

The next logic is that if there is nothing elsetagPointing to the storage layer will actually delete the storage layer, and then continue to query whether the storage layer of the next layer is still in use, and will not continue to delete until a layer finds that there are containers or mirrors that depend on the storage layer, and then stop deleting. So when you executedocker rmiWhen, can observe how many appearedDeleted: sha256: ...This is how many layers have been deleted and the others have not.

So if you start overdocker tagThe mysql image, then when you executedocker rmiWhen, will only be executeduntagWithout actually deleting the storage tier.

Or the system has other images based on the same basic imagedebian:jessieYes, thendocker rmiAlso will only delete to this layer will stop, after every timepullIt also starts from this floor.

Similarly, this concept of tiered storage will also affect youdocker pull. When you executedocker pullWhen, will check the officialdocker:latestThe check value of each layer of the, and then to the local comparison, see which already exist, if there is not repeat pull, directly use the current storage layer, pull the new if there is no.

Take what you just said. If you try againdocker tagFor example, if you re-start beforetagGo through thismysql:latestMirror image, thendocker rmiThe mirror is not actually deleted and againdocker pull mysqlWhen I found that all storage layers are locally available, it is inevitable that I don’t need to pull again and directly transfer the top layertagFormysql:latestJust. There is no need to worry about this situation or force it to be downloaded again, becausesha256sumIt can ensure the consistency between the image file and the official website.

So your question depends on the specific situation. Generally speaking, it is not recommended in production environment.latestLabel, but explicitly specify the version, so that maintenance can be upgraded.