1

Use this way to deploy an application which has been built as a docker image hosted on ecr:

version: "3"
services:
  web:
    image: [AWS_ECR_REPO_URL]/app0:latest
    deploy:
      replicas: 5
      restart_policy:
        condition: on-failure
      resources:
        limits:
          cpus: "0.1"
          memory: 50M
    ports:
      - "80:80"
    networks:
      - webnet
networks:
  webnet:

Deploy it:

$ docker stack deploy -c docker-compose.yml app0

Then use docker images to check the images local, can't find the [AWS_ECR_REPO_URL]/app0:latest at all.

If pull the repo myself, it can be get:

$ docker pull [AWS_ECR_REPO_URL]/app0:latest

I don't know why.

v v
  • 613
  • 3
  • 10
  • 26

1 Answers1

2
  • Enter your credentials using docker login if you want to pull the private image.

  • Specify server name want to login into self-hosted registry

    docker login server-name (localhost)

  • Use --with-registry-auth option for swarm

    docker stack deploy --with-registry-auth

Haresh Chhelana
  • 24,720
  • 5
  • 57
  • 67
  • I have did that. As I said I can pull the image using this way: `docker pull [AWS_IMAGE]`. But can't pull automatically by run `docker stack deploy ...`. – v v May 24 '18 at 05:14
  • Have you check --with-registry-auth with swarm (stack deploy)? Ref. https://stackoverflow.com/questions/45567201/user-docker-compose-to-pull-images-from-private-repository?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Haresh Chhelana May 24 '18 at 05:26
  • That's the key point. It works when I added `--with-registry-auth`! Thanks! – v v May 24 '18 at 06:54