Failure with Caddyfile mounting in docker compose image

1. Caddy version (caddy version):


2. How I run Caddy:

sudo socker-compose up

a. System environment:

Ubuntu 20.04 - Fully updated
Docker version 20.10.3, build 48d30b5
docker-compose version 1.28.4, build cabd5cfb

b. Command:

sudo docker-compose up

c. Service/unit/compose file:

version: "3.7"

    image: caddy:2.3.0
    restart: unless-stopped
      - "80:80"
      - "443:443"
      - $PWD/Caddyfile:/etc/caddy/Caddyfile
      - $PWD/site:/srv
      - caddy_data:/data
      - caddy_config:/config


d. My complete Caddyfile or JSON config:


respond "Hello, world!"

3. The problem Iā€™m having:

Thge container refuses to mount the Caddyfile to the container.

4. Error messages and/or full log output:

ERROR: for documents_caddy_1  Cannot start service caddy: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: rootfs_linux.go:59: mounting "/Caddyfile" to rootfs at "/var/lib/docker/overlay2/3c1cbcc34dbdad2ab5db41e7d43457715483797817c3351a8e6596cdb43e1c41/merged/etc/caddy/Caddyfile" caused: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

5. What I already tried:

Running as sudo.
Checking the Caddyfile is not a directory.
Ensuring I run docker-compose up command from the folder containing the Caddyfile

6. Links to relevant resources:

No resources. Just trying to get caddy running

Where do you expect the Caddyfile to be?

In this case PWD is /srv on not the actual path you running the container from.

Try binding with a full path ie



Thanks man. Noob mistake at its finest. Makes sense now you expained it :slight_smile:

1 Like

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