Docker Lookup Server misbehaving

1. The problem I’m having:

I have caddy and a service (immitch) spun up from two docker compose files (makes managing easier for me) and both joined to a manually created caddy network. Immitch has its port exported, In the caddy file I set up a reverse proxy to the exported port on the immitch server using the container name as the uri. When I try and visit the url however there seems to be a DNS issue with caddy unable to lookup the container as 127.0.0.11:53 is misbehaving.

Docker networks inspect caddy shows both containers are connected as expected. If i replace the hostname with the immitch container ip in the caddy network everything works fine. Server is currently running with the IP in the caddyfile so will work if you check, but this changes every time a container is resarted so is less than ideal.

I’m fairly new to docker and am at a loss what may be going wrong with the DNS or how to debug it further, any advice is most appreciated.

2. Error messages and/or full log output:

 {"level":"error","ts":1703949679.5659037,"logger":"http.log.error","msg":"dial tcp: lookup immitch_server on 127.0.0.11:53: server misbehaving","request":{"remote_ip":"109.157.177.195","remote_port":"52380","client_ip":"109.157.177.195","proto":"HTTP/2.0","method":"GET","host":"photos.aroyo.co.uk","uri":"/manifest.json","headers":{"Sec-Fetch-Site":["same-origin"],"Cookie":[],"Sec-Fetch-Dest":["manifest"],"Accept-Encoding":["gzip, deflate, br"],"Accept":["*/*"],"Accept-Language":["en-GB,en;q=0.9"],"Sec-Fetch-Mode":["cors"],"User-Agent":["Mozilla/5.0 (iPad; CPU OS 17_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1"],"Referer":["https://photos.aroyo.co.uk/photos"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"photos.aroyo.co.uk"}},"duration":0.001771817,"status":502,"err_id":"ztmxf2q99","err_trace":"reverseproxy.statusError (reverseproxy.go:1267)"}

3. Caddy version:

v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=

4. How I installed and ran Caddy:

a. System environment:

Docker on Ubuntu

b. Command:

docker compose up -d

c. Service/unit/compose file:

Caddy

version: "3.9"

services:
  caddy:
    image: caddy:latest
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./site:/srv
      - caddy_data:/data
      - caddy_config:/config
    networks:
      - caddy
      - default
    extra_hosts:
      - "host.docker.internal:host-gateway"

volumes:
  caddy_data:
  caddy_config:

networks:
  caddy:
    external: true

Immitch

version: "3.9"

#
# WARNING: Make sure to use the docker-compose.yml of the current release:
#
# https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
#
# The compose file on main may not be compatible with the latest release.
#

name: immich

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: [ "start.sh", "immich" ]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    expose:
      - 3001
    depends_on:
      - redis
      - database
    restart: always
    networks:
      - caddy
      - default

  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    # extends:
    #   file: hwaccel.yml
    #   service: hwaccel
    command: [ "start.sh", "microservices" ]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    depends_on:
      - redis
      - database
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always

  redis:
    container_name: immich_redis
    image: redis:6.2-alpine@sha256:b6124ab2e45cc332e16398022a411d7e37181f21ff7874835e0180f56a09e82a
    restart: always

  database:
    container_name: immich_postgres
    image: tensorchord/pgvecto-rs:pg14-v0.1.11@sha256:0335a1a22f8c5dd1b697f14f079934f5152eaaa216c09b61e293be285491f8ee
    env_file:
      - .env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: always

volumes:
  pgdata:
  model-cache:

networks:
  caddy:
    external: true

d. My complete Caddy config:

# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.

{
        debug
}

photos.aroyo.co.uk {
        reverse_proxy immitch_server:3001
        encode zstd gzip
}

5. Links to relevant resources:

Your container name is:

But you told Caddy to proxy to:

There’s an extra “t” in “immich” in your Caddyfile :slight_smile:

1 Like

oh my goodness im an Idiot! Though to be fair server misbehaving is hardly a useful error for name not found!

1 Like

Yeah, that comes from the DNS resolver. I’m not sure how we could detect or help with that.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.