Problem with Caddy and Docker

(Bill Moran) #1

Tried to create a Caddy container by running:

$docker run -d -v $(pwd)/Caddyfile:/etc/Caddyfile --name=caddy --network=wordpress -p 8443:8443 abiosoft/caddy

It spits out this error:

Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused “process_linux.go:402: container init caused “rootfs_linux.go:58: mounting \”/home/bill/webwork/mission/Caddyfile\” to rootfs \"/var/lib/docker/overlay2/3937f287a3f13e8ae95dff03a51fce4390765b1b08a989dc9b1392f20a007049/merged\" at \"/var/lib/docker/overlay2/3937f287a3f13e8ae95dff03a51fce4390765b1b08a989dc9b1392f20a007049/merged/etc/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.

I had a Wordpress container and figured it was possible that the php-fpm container may have a conflicting path. I removed it and still get the same error. Then, after reading another post on here felt it was possible that the path was going to a folder and not the Caddyfile. When I tried to re-run it assuming so, it created another Caddyfile folder, but it did not contain a Caddyfile, which I think may be what my real problem is.

I apologize in advance. Both Caddy and Docker are new to me. I was running Vagrant for my local work before, but felt this was the direction I should take my setup after seeing Matt Holt’s comments on a Youtube video from Chrome Devs about using Wordpress as a PWA. Thanks for taking a look.

(Matthew Fay) #2

Hi @BMo,

This issue is mostly unrelated to Caddy, and applies to any setup involving Docker volumes.

Inside the container, /etc/Caddyfile is a plain text file (containing a simple default configuration).

When you mount a volume, you’re overlaying the nominated file or directory inside the container, hiding the original one. The overlaid volume must be of the same type as the underlying one.

Volumes have to be explicitly declared, so conflict over a volume between containers won’t happen unless you specify the same volume mount for those containers.

In this case, you would need to be able to run cat $(pwd)/Caddyfile from the host and see the Caddyfile text you want to replace the default with.