简体   繁体   English

Docker私有注册表-删除容器后访问注册表映像

[英]Docker Private registry - access registry images after container is removed

I created a private docker registry and successfully pushed and pulled some images. 我创建了一个私有Docker注册表并成功推送和提取了一些图像。

The thing is, the private registry runs in a container and when I remove the container using 事实是,私有注册表在容器中运行,当我使用删除容器时

sudo docker rm [container name]

I realize that all my pushed images are lost after a new container has been created. 我意识到在创建新容器后,所有推送的图像都会丢失。

Is there a way to keep the images in a private registry even when that private registry container is removed and another created? 有一种方法可以将图像保留在私有注册表中,即使已删除该私有注册表容器并创建了另一个容器?

If you start your registry using the dev or local config (assuming the default sample config ), you can map the storage_path directory to a directory on the host machine using a volume mount -v . 如果使用devlocal配置启动注册表(假设使用默认示例config ),则可以使用volume mount -vstorage_path目录映射到主机上的目录。

Using a modified version of the quick start example: 使用快速入门示例的修改版本:

docker run \
    -d --name registry \
    -e SETTINGS_FLAVOR=local \
    -e STORAGE_PATH=/registry \
    -v /tmp/registry:/registry \
    -p 5000:5000 \
    registry

This will store the registry's data on the host machine in /tmp/registry , and persist when the container stops. 这会将注册表的数据存储在/tmp/registry的主机上,并在容器停止时保留。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM