Search code examples
azuredockerdocker-compose

Error Deploying Docker Compose to Azure Container Instances: Image Pull Access Denied


I am encountering issues while trying to deploy a Docker Compose application in my web app in azure. I am trying to use my Azure Container registries . The deployment fails with an error related to image pull access being denied. I have a Docker Compose file defining my services, and the images are stored in an Azure Container Registry. I have a web app that using my docker compose.

my docker compose file:

version: '3'
services:
  # ChromaDB service
  chromadb:
    image: chromadb/chroma:latest
    container_name: chromadb
    ports:
      - "8001:8000"
    volumes:
      - chroma_data:/chroma/.chroma

  # MongoDB service
  mongo:
    image: mongo:latest
    container_name: mongodb
    ports:
      - "27017:27017"
    volumes:
      - mongo_data:/data/db

  # Your FastAPI service
  fastapi:
    image: webmedinsight/rmed1:build-tag-1
    container_name: fastapi_app
    ports:
      - "8000:8000"
    depends_on:
      - chromadb
      - mongo
    environment:
      MONGO_HOST: mongo  # Use service name for MongoDB connection

volumes:
  chroma_data:
  mongo_data:

my repository:

In my container regeistry

in my web app in the configuration I added the command docker-compose up --build

my logs erros in my web app on azure

2024-03-11T19:06:17.632Z ERROR - multi-container unit was not started successfully
2024-03-11T19:06:17.634Z INFO  - Container logs from webmedinsight_chromadb_0_7f4075c9 =
2024-03-11T19:06:17.687Z INFO  - Container logs from webmedinsight_mongo_0_7f4075c9 =
2024-03-11T19:06:17.757Z INFO  - Container logs from webmedinsight_fastapi_0_7f4075c9 =
2024-03-11T19:06:17.897Z INFO  - Stopping site webmedinsight because it failed during startup.
2024-03-11T19:07:20  No new trace in the past 1 min(s).
2024-03-11T19:08:20  No new trace in the past 2 min(s).
2024-03-11T19:08:38.419Z INFO  - Starting multi-container app..
2024-03-11T19:08:39.545Z INFO  - Pulling image: chromadb/chroma:latest
2024-03-11T19:08:40.626Z ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Head \"https://registry-1.docker.io/v2/chromadb/chroma/manifests/latest\": unauthorized: incorrect username or password"}
2024-03-11T19:08:40.627Z ERROR - Pulling docker image chromadb/chroma:latest failed:
2024-03-11T19:08:42.234Z INFO  - latest Pulling from chromadb/chroma
2024-03-11T19:08:42.260Z INFO  -  Digest: sha256:8173dd30e370f67a859297a9d2bca138ec527bc9c5a08582fb6951341716f313
2024-03-11T19:08:42.261Z INFO  -  Status: Image is up to date for chromadb/chroma:latest
2024-03-11T19:08:42.267Z INFO  - Pull Image successful, Time taken: 1 Seconds
2024-03-11T19:08:42.279Z INFO  - Starting container for site
2024-03-11T19:08:42.280Z INFO  - docker run -d -p 7239:8000 --name webmedinsight_chromadb_0_c2ff9435 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=webmedinsight -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=webmedinsight.azurewebsites.net -e WEBSITE_INSTANCE_ID=aa5a7b1e3d657bb5e200ae7d4b6324379854db652dc7780ea09b7547b87142de chromadb/chroma:latest
2024-03-11T19:08:42.280Z INFO  - Logging is not enabled for this container.Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2024-03-11T19:08:42.386Z INFO  - Pulling image: mongo:latest
2024-03-11T19:08:43.351Z ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Head \"https://registry-1.docker.io/v2/library/mongo/manifests/latest\": unauthorized: incorrect username or password"}
2024-03-11T19:08:43.352Z ERROR - Pulling docker image mongo:latest failed:
2024-03-11T19:08:44.766Z INFO  - latest Pulling from library/mongo
2024-03-11T19:08:44.793Z INFO  -  Digest: sha256:eb47cdea510f092cad3e76d5a4e7135a6b7b7b0fcc27be15859e1a312c4e2c68
2024-03-11T19:08:44.794Z INFO  -  Status: Image is up to date for mongo:latest
2024-03-11T19:08:44.801Z INFO  - Pull Image successful, Time taken: 1 Seconds
2024-03-11T19:08:44.814Z INFO  - Starting container for site
2024-03-11T19:08:44.815Z INFO  - docker run -d  --name webmedinsight_mongo_0_c2ff9435 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=webmedinsight -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=webmedinsight.azurewebsites.net -e WEBSITE_INSTANCE_ID=aa5a7b1e3d657bb5e200ae7d4b6324379854db652dc7780ea09b7547b87142de mongo:latest
2024-03-11T19:08:44.815Z INFO  - Logging is not enabled for this container.Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2024-03-11T19:08:44.971Z INFO  - Pulling image: webmedinsight/rmed1:build-tag-1
2024-03-11T19:08:46.048Z ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Head \"https://registry-1.docker.io/v2/webmedinsight/rmed1/manifests/build-tag-1\": unauthorized: incorrect username or password"}
2024-03-11T19:08:46.050Z ERROR - Pulling docker image webmedinsight/rmed1:build-tag-1 failed:
2024-03-11T19:08:47.751Z ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"pull access denied for webmedinsight/rmed1, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"}
2024-03-11T19:08:47.752Z WARN  - Image pull failed. Defaulting to local copy if present.
2024-03-11T19:08:47.755Z ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2024-03-11T19:08:47.756Z ERROR - multi-container unit was not started successfully
2024-03-11T19:08:47.760Z INFO  - Container logs from webmedinsight_chromadb_0_c2ff9435 =
2024-03-11T19:08:47.820Z INFO  - Container logs from webmedinsight_mongo_0_c2ff9435 =
2024-03-11T19:08:47.891Z INFO  - Container logs from webmedinsight_fastapi_0_c2ff9435 =
2024-03-11T19:08:48.024Z INFO  - Stopping site webmedinsight because it failed during startup.

When I run my app locally with the docker compose the app is working, I don't understand how to fix it, thanks for any help (:


Solution

  • I guess from your question that webmedinsight/rmed1 is your custom Docker image. Locally you must be building and tagging your image manually before starting the Docker Compose stack, so that it will be stored in your local Docker registry. Otherwise, Docker would search the image on the default remote registry: Docker Hub.

    It looks like you built, tagged and pushed your image to a private remote registry on Azure. To do so, you must have tagged your image with a specific name that includes the registry domain (something like my-registry.some-azure-domain.com/my-image:my-tag) and login before pushing.

    The same logic goes with a deployment: by using your local image tag, Docker will look into the local registry (local = server), and search for it on Docker Hub if it can't be found.
    Your Docker Compose file should include the complete name with registry address and you should log into your registry before starting the stack.

    See: