caddy-docker
caddy-docker copied to clipboard
Issues with mounting $(pwd)/Caddyfile
Hi, I'm currently having trouble with mounting the Caddyfile into the container:
jannik@cheesegrater:/tmp/caddy$ ls
Caddyfile index.html
jannik@cheesegrater:/tmp/caddy$ stat Caddyfile
File: Caddyfile
Size: 21 Blocks: 0 IO Block: 512 regular file
Device: 2h/2d Inode: 3096224744076277 Links: 1
Access: (0666/-rw-rw-rw-) Uid: ( 1000/ jannik) Gid: ( 1000/ jannik)
Access: 2018-10-24 21:52:53.310144100 +0200
Modify: 2018-10-24 21:52:53.311139600 +0200
Change: 2018-10-24 21:52:53.311139600 +0200
Birth: -
jannik@cheesegrater:/tmp/caddy$ cat Caddyfile
https://cheesegrater
jannik@cheesegrater:/tmp/caddy$ docker run -it \
> -v $(pwd)/Caddyfile:/etc/Caddyfile \
> -p 80:80 -p 443:443 abiosoft/caddy
docker: 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 \\\"/tmp/caddy/Caddyfile\\\" to rootfs \\\"/var/lib/docker/overlay2/bb(...)5f/merged\\\" at \\\"/var/lib/docker/overlay2/bb(...)95f/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.
Do you have any idea what might help in such a case? I'm using abiosoft/caddy in a larger production env, but this small environment does not want to work. 😞
What platform are you on and are you sure the container has access to /tmp
directory?
Where you able to resolve this? I am trying to create this container and I am stuck in this part. I also try creating the path my self and I have the same results
+1, am having the same issue but got it fixed.
I'm on kubuntu 18.04, arch x86_64
, Docker version 18.09.7, build 2d0083d
Note that the exact path in on a link to an external drive which got disconnected during operation and was reconnecting. Because the drive got disconnected, docker (which runs with root) recreated that exact path. When the drive got connected again, the directory with the path already existed and a new HDD-path was picked, hence the file could not be found anymore.
Anyway, for context: my error logs and docker compose config.
letsencrypt:
image: abiosoft/caddy
container_name: letsencrypt
ports:
- 443:443
- 80:80
volumes:
- /media/pietervdvn/d6114b2c-5cad-4eb5-b1d9-6e35dade7003/all/pietervdvn-projecten/Server/CaddyFile:/etc/Caddyfile
- /home/pietervdvn/nextcloudcert:/root/.caddy
restart:
always
environment:
- ACME_AGREE=true
The complete error message is:
ERROR: for letsencrypt Cannot start service letsencrypt: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:430: container init caused \"rootfs_linux.go:58: mounting \\\"/media/pietervdvn/d6114b2c-5cad-4eb5-b1d9-6e35dade7003/all/pietervdvn-projecten/Server/CaddyFile\\\" to rootfs \\\"/var/lib/docker/overlay2/d7607a7747ab5f8b6fe72291ea73d1d75bc4147d4a7d0e1a1b49a0b39896d59e/merged\\\" at \\\"/var/lib/docker/overlay2/d7607a7747ab5f8b6fe72291ea73d1d75bc4147d4a7d0e1a1b49a0b39896d59e/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
ERROR: for letsencrypt Cannot start service letsencrypt: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:430: container init caused \"rootfs_linux.go:58: mounting \\\"/media/pietervdvn/d6114b2c-5cad-4eb5-b1d9-6e35dade7003/all/pietervdvn-projecten/Server/CaddyFile\\\" to rootfs \\\"/var/lib/docker/overlay2/d7607a7747ab5f8b6fe72291ea73d1d75bc4147d4a7d0e1a1b49a0b39896d59e/merged\\\" at \\\"/var/lib/docker/overlay2/d7607a7747ab5f8b6fe72291ea73d1d75bc4147d4a7d0e1a1b49a0b39896d59e/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
ERROR: Encountered errors while bringing up the project.
I just bumped into this error and the fix was relatively simple. I was starting off in a directory with just a docker-compose.yml
like the one below. I'd run docker-compose up
which would create a certs
and Caddyfile
directory. The keyword was directory, Caddy expects /etc/Caddyfile
to be a flat file. All I had to do to fix this was delete the Caddyfile
directory, run touch Caddyfile
, then docker-compose up
again and it started up no problem.
File Structure
-rw-r--r--. 1 root root 110 Jan 3 16:24 Caddyfile
drwxr-xr-x. 4 root root 43 Jan 3 16:30 certs
-rw-r--r--. 1 root root 418 Jan 3 16:34 docker-compose.yml
docker-compose.yml
version: '3'
services:
caddy:
image: "abiosoft/caddy:latest"
container_name: caddy
volumes:
- /root/caddy/certs:/root/.caddy
- /root/caddy/Caddyfile:/etc/Caddyfile
ports:
- "2015:2015"
- "80:80"
- "443:443"
external_links:
- home-assistant
environment:
- ACME_AGREE=true