DNS resolution error when installing docker registry

I use docker-compose to start localstack on macbook m1 (arm64). When I run cdklocal bootstrap, it fails with

CREATE_FAILED        | AWS::ECR::Repository    | ContainerAssetsRepository
An error occurred (RepositoryAlreadyExistsException) when calling the CreateRepository operation: The repository with name 'cdk-hnb659fds-container-assets-000000000000-us-east-1' already exists in the registry with id '000000000000'

In localstack logs I see it was unable to resolve DNS and download failed

localstack  | 2023-12-14T20:48:04.006 DEBUG --- [functhread15] l.s.c.resource_provider    : Running action "Add" for resource type "AWS::ECR::Repository" id "ContainerAssetsRepository"
localstack  | 2023-12-14T20:48:04.010 DEBUG --- [functhread15] l.s.c.resource_provider    : Request for resource type "AWS::ECR::Repository" in account 000000000000 region us-east-1: create_repository {'repositoryName': 'cdk-hnb659fds-container-assets-000000000000-us-east-1', 'tags': [], 'imageTagMutability': 'IMMUTABLE', 'imageScanningConfiguration': {'scanOnPush': False}, 'encryptionConfiguration': {'encryptionType': 'AES-256'}}
localstack  | 2023-12-14T20:48:04.101  INFO --- [   asgi_gw_0] l.services.ecr.provider    : Starting ECR Docker registry on port 4510
localstack  | 2023-12-14T20:48:04.102 DEBUG --- [   asgi_gw_0] localstack.packages.api    : Starting installation of docker-registry...
localstack  | 2023-12-14T20:48:04.103  INFO --- [uest_thread)] localstack.dns.server      : Unable to get DNS result from upstream server 1 for domain github.com.: 
localstack  | 2023-12-14T20:48:04.104  WARN --- [   asgi_gw_0] localstack.utils.archives  : Attempt 1. Failed to download archive from https://github.com/localstack/localstack-artifacts/raw/1cc593407191bb24f859a718cd9ed884363b4a57/docker-registry/registry.linux-arm64.zip: MyHTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /localstack/localstack-artifacts/raw/1cc593407191bb24f859a718cd9ed884363b4a57/docker-registry/registry.linux-arm64.zip (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0xffff501885d0>: Failed to resolve 'github.com' ([Errno -5] No address associated with hostname)"))
localstack  | 2023-12-14T20:48:05.214  INFO --- [   asgi_gw_1] localstack.request.aws     : AWS cloudformation.DescribeStackEvents => 200
localstack  | 2023-12-14T20:48:05.233  INFO --- [   asgi_gw_1] localstack.request.aws     : AWS cloudformation.DescribeStackEvents => 200
localstack  | 2023-12-14T20:48:07.112  INFO --- [uest_thread)] localstack.dns.server      : Unable to get DNS result from upstream server 1 for domain github.com.: 
localstack  | 2023-12-14T20:48:07.113  WARN --- [   asgi_gw_0] localstack.utils.archives  : Attempt 2. Failed to download archive from https://github.com/localstack/localstack-artifacts/raw/1cc593407191bb24f859a718cd9ed884363b4a57/docker-registry/registry.linux-arm64.zip: MyHTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /localstack/localstack-artifacts/raw/1cc593407191bb24f859a718cd9ed884363b4a57/docker-registry/registry.linux-arm64.zip (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0xffff501a3450>: Failed to resolve 'github.com' ([Errno -5] No address associated with hostname)"))

Has anyone experience with that?

My docker compose is pretty simple:

version: "3.8"

services:
  localstack:
    container_name: localstack
    image: localstack/localstack-pro
    ports:
      - "127.0.0.1:4566:4566"            # LocalStack Gateway
      - "127.0.0.1:4510-4559:4510-4559"  # external services port range
      - "127.0.0.1:53:53"                # DNS config (required for Pro)
      - "127.0.0.1:53:53/udp"            # DNS config (required for Pro)
      - "127.0.0.1:443:443"              # LocalStack HTTPS Gateway (required for Pro)
    environment:
      DEBUG: ${DEBUG}
      LS_LOG: ${LS_LOG}
      PERSISTENCE: 0
      LOCALSTACK_AUTH_TOKEN: ${LOCALSTACK_AUTH_TOKEN}
      DOCKER_HOST: unix:///var/run/docker.sock
      DNS_SERVER: 1
      ECS_REMOVE_CONTAINERS: 0
      LAMBDA_DOCKER_NETWORK: network-dev
      AWS_ACCESS_KEY_ID: test
      AWS_SECRET_ACCESS_KEY: test
      AWS_DEFAULT_REGION: us-east-1
      DEFAULT_REGION: us-east-1
    volumes:
      - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"
    healthcheck:
      test: ["CMD", "curl", "http://localhost:4566/_localstack/health?reload"]
      interval: 10s
      timeout: 5s
      retries: 10

Hi @PetrPokorny,

I believe the DNS_SERVER is not set correctly. Please provide a proper IP address.

More information in our documentation DNS Server | Docs (localstack.cloud) and Configuration | Docs (localstack.cloud).

If it does not work I would suggest to try it again with the default docker-compose.yml.

1 Like

Yes indeed, the problem was DNS_SERVER: 1 environment variable. It must be IP address if used. I removed it and it started working. Thank you very much for your help!