[英]Docker pushing containers to private registry
I have an app which uses several docker containers: 我有一个使用多个Docker容器的应用程序:
Since I'm using existing images for two of the above containers, I also have two cached containers: 由于我将现有图像用于上述两个容器,因此我也有两个缓存的容器:
I'm trying to push my containers (1, 2, & 3) to AWS Elastic Container Registry (ECR). 我正在尝试将我的容器(1、2和3)推送到AWS Elastic Container Registry(ECR)。 I've been able to do this, but have noticed that my cached containers (4 & 5) get pushed too.
我已经能够做到这一点,但是注意到我的缓存容器(4和5)也被推送了。
I'm building the containers using docker-compose
, and then tagging like so: 我正在使用
docker-compose
构建容器,然后像这样标记:
docker tag -f nodejs_app:latest <repository URL>:latest
After logging into ECR with docker login
, I push using this command: 使用
docker login
登录到ECR之后,我使用以下命令进行推送:
docker push <repository URL>:latest
Docker then pushes all 5 containers up into the registry. 然后,Docker将所有5个容器推入注册表。 How do I only push the containers that I care about and not the cached ones too?
如何只推送我关心的容器,而不推送缓存的容器?
Thanks in advance :-) 提前致谢 :-)
How do I only push the containers that I care about and not the cached ones too?
如何只推送我关心的容器,而不推送缓存的容器?
You don't. 你不知道
Docker images (not containers ; a container is what you get when you boot an image ) are built from layers. Docker映像(不是容器 ;容器是引导映像时获得的容器)是从层构建的。 Your
nginx
image, for example, consists of all the layers from the alpine
image, followed by any layers that are created as the result of your Dockerfile
. 例如,您的
nginx
映像包括alpine
映像中的所有层,然后是Dockerfile
的结果所创建的任何层。
In order for your new image to be stored in a private repository, all the underlying layers need to be available . 为了将新映像存储在私有存储库中, 所有基础层都必须可用 。 This means that in addition to the layers you create via your
Dockerfile
, all the layers from the alpine
image also need to be pushed to the repository as well. 这意味着,除了通过
Dockerfile
创建的图层外, alpine
映像中的所有图层也都需要推送到存储库中。
So if you build an image on top of the alpine
image and push it to a private repository, the alpine
image will get pushed there as well. 因此,如果您在
alpine
图像上构建图像并将其推送到私有存储库,那么alpine
图像也将被推送到那里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.