docker-compose thinks file is a directory

Viewed 1068

Any ideas?

This service was starting before but now I get this '/etc/Caddyfile: is a directory' message and the service Exits.

$ docker-compose -f docker-compose-linux.yml up caddy
Starting server_applications_1 ... done
server_workspace_1 is up-to-date
server_php-fpm_1 is up-to-date
Starting server_caddy_1        ... done
Attaching to server_caddy_1
caddy_1         | http plugins loaded: git
caddy_1         | 2020/06/22 06:22:18 loading Caddyfile via flag: read /etc/Caddyfile: is a directory
server_caddy_1 exited with code 1

the caddy service dockerfile:

FROM zuohuadong/caddy:alpine
MAINTAINER Huadong Zuo <admin@zuohuadong.cn>
ARG plugins="cors"
WORKDIR /var/www/platform/public
CMD ["/usr/bin/caddy", "-conf", "/etc/Caddyfile"]

the Caddy service container yml: where CADDY_CUSTOM_CADDYFILE=./caddy/Caddyfile

      volumes:
        - ${CADDY_CUSTOM_CADDYFILE}:/etc/Caddyfile

and the Caddyfile is there in the right directory

...server/caddy$ ll
total 16
drwxrwxr-x  2 ubuntu ubuntu 4096 Jun 22 17:44 ./
drwxrwxr-x 11 ubuntu ubuntu 4096 Jun 22 15:55 ../
-rw-r--r--  1 ubuntu ubuntu 1452 Jun 11 10:54 Caddyfile
-rw-r--r--  1 ubuntu ubuntu  268 Jun 22 18:13 Dockerfile

$ docker-compose -f docker-compose-linux.yml up caddy

Starting server_applications_1 ... done server_workspace_1 is up-to-date server_php-fpm_1 is up-to-date Starting server_caddy_1 ... done Attaching to server_caddy_1 caddy_1 | http plugins loaded: git caddy_1 | 2020/06/22 06:22:18 loading Caddyfile via flag: read /etc/Caddyfile: is a directory server_caddy_1 exited with code 1

1 Answers

Can you try to mount directory instead of file in your docker compose.

      volumes:
        - ${CADDY_CUSTOM_CADDYFILE}:/etc

where CADDY_CUSTOM_CADDYFILE=full_Path_to/caddy/

you will still be able to use

CMD ["/usr/bin/caddy", "-conf", "/etc/Caddyfile"]
Related