Docker pushing containers to private registry

I have an app which uses several docker containers:

  1. NGINX container
  2. NodeJS sails app container
  3. Redis cache container

Since I’m using existing images for two of the above containers, I also have two cached containers:

  • Why docker stops already running containers during startup?
  • Piping docker run container ID to docker exec
  • How to start Jenkins slave on docker-cloud?
  • How to set hwaddr in docker 0.9.x
  • Docker 500 error
  • Microsoft Compiler in Docker
    1. alpine
    2. redis

    I’m trying to push my containers (1, 2, & 3) to AWS Elastic Container Registry (ECR). I’ve been able to do this, but have noticed that my cached containers (4 & 5) get pushed too.

    I’m building the containers using docker-compose, and then tagging like so:

    docker tag -f nodejs_app:latest <repository URL>:latest

    After logging into ECR with docker login, I push using this command:

    docker push <repository URL>:latest

    Docker then pushes all 5 containers up into the registry. How do I only push the containers that I care about and not the cached ones too?

    Thanks in advance 🙂

  • Running Docker in Memory?
  • Open port between docker containers
  • Fleetctl job already exists
  • Running openshift origin on mac 10.11.6 with docker version 1.12.0
  • How can I reflect the data in one container to another?
  • udp client server program communication to ibm bluemix containers
  • One Solution collect form web for “Docker pushing containers to private registry”

    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. 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.

    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.

    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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.