I can't get this to initialize in Docker

I entered this info from the caddy site into my compose file:

version: "3.7"

services:
  caddy:
    image: caddy:<version>
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - $PWD/Caddyfile:/etc/caddy/Caddyfile
      - $PWD/site:/srv
      - caddy_data:/data
      - caddy_config:/config

volumes:
  caddy_data:
  caddy_config:

However, I’m getting the following error when I try to bring it up:

Starting docker_caddy_1 … error

ERROR: for docker_caddy_1 Cannot start service caddy: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: rootfs_linux.go:60: mounting “/home/mike/docker/Caddyfile” to rootfs at “/var/lib/docker/overlay2/50cb6e19f82e192e267a233157d14da3002ef1e22aec04a9f08e904eeb77cddf/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

ERROR: for caddy Cannot start service caddy: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: rootfs_linux.go:60: mounting “/home/mike/docker/Caddyfile” to rootfs at “/var/lib/docker/overlay2/50cb6e19f82e192e267a233157d14da3002ef1e22aec04a9f08e904eeb77cddf/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
ERROR: Encountered errors while bringing up the project.

Any ideas?

Did you create a file at $PWD/Caddyfile before running it? You need to have your Caddyfile ready on the host machine first. Docker can’t create a mount for a file that doesn’t exist.

Next time, please fill out the help topic template. It’s important to save time to help you.

Thanks for the insanely fast response! No, I did not create a caddy file. I haven’t gotten that far. This is just a simple reverse proxy with two hosts.

host1.domain.com=thismachine:8000
host2.domaint.com=thismachine:8001

Also, sorry for not filling out the form.

Well that needs to be done before you run Caddy.

Caddy can’t run without a config.

I appreciate that Francis. I did not see in that link, an example of a reverse proxy caddyfile, for which I am trying to configure. Is there another link?

Alright, I created the file and still no go. Let me paste some specifics so you might be able to better assist.

Caddy is being run via docker compose on an Ubuntu Server 20.04 VM.
docker compose is:

caddy:
image: caddy:latest
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- /home/mike/caddy/Caddyfile:/etc/caddy/Caddyfile
- /home/mike/caddy:/srv
- caddy_data:/data
- caddy_config:/config

volumes:
caddy_data:
caddy_config:

inside /home/mike/docker/caddy I have “Caddyfile” which is:

mike@ubuntumedia:~/docker/caddy$ cat Caddyfile
ombi.digitalwashu.net

reverse_proxy 192.168.1.10:3579

running docker compose brings up:

mike@ubuntumedia:~/docker$ docker-compose up -d
Removing docker_caddy_1
ombi is up-to-date
jellyfin is up-to-date
Recreating 6fd78d80eaa9_docker_caddy_1 …
sabnzbd is up-to-date
radarr is up-to-date
Recreating 6fd78d80eaa9_docker_caddy_1 … error

ERROR: for 6fd78d80eaa9_docker_caddy_1 Cannot start service caddy: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: rootfs_linux.go:60: mounting “/home/mike/caddy/Caddyfile” to rootfs at “/var/lib/docker/overlay2/d8522d415da5be1141fb02b77792bfa113f28aec05c63adc2b1e1730f1bd37f2/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

ERROR: for caddy Cannot start service caddy: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: rootfs_linux.go:60: mounting “/home/mike/caddy/Caddyfile” to rootfs at “/var/lib/docker/overlay2/d8522d415da5be1141fb02b77792bfa113f28aec05c63adc2b1e1730f1bd37f2/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
ERROR: Encountered errors while bringing up the project.

I’m not sure where to go from here. Do you want to see my pastes from the firewall rules?

Your paths aren’t the same. One has /docker and the other doesn’t.

Ty, and I just fixed that, so now the container loads properly. I’m not getting any reverse proxying though. Did you see anything incorrect with my Caddyfile syntax? I’m trying to forward ombi.digitalwashu.net to 192.168.1.10:3579.

I’m thinking possibly I’m having firewall issues if you think the Caddyfile looks good.

Is this a different machine in your network?

What do you see when you make the request with curl -v? Are you trying the request from inside your network? What if you try from your phone?

What’s in Caddy’s logs? Run docker-compose logs caddy to see them.

The help topic template asks all these questions.

I’m really sorry I didn’t follow the help template. I realize this has cost you time. I will make sure to get the technical answers youre looking for. sorry again.

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