abiosoft / caddy-docker

Docker container for Caddy
https://hub.docker.com/r/abiosoft/caddy/
MIT License
766 stars 314 forks source link

How to build my own image with a custom Caddyfile #214

Open ighormartins opened 4 years ago

ighormartins commented 4 years ago

I need to build and export an image with a custom Caddyfile inside it.

I tried something as simple as:

FROM abiosoft/caddy:latest

COPY Caddyfile /etc/Caddyfile

However, the container is always restarting and the server won't start.

abiosoft commented 4 years ago

Can you share the error log?

Also you can temporarily RUN cat /etc/Caddyfile in the build process to be sure the copy was successful.

ighormartins commented 4 years ago

Of course It goes all fine while building the image:

Status: Downloaded newer image for abiosoft/caddy:latest
 ---> f2eece677796
Step 2/4 : COPY Caddyfile /etc/Caddyfile
 ---> 7c336a0c0ec4
Step 3/4 : RUN cat /etc/Caddyfile
 ---> Running in 5ade95d29a7e
the.url {
    proxy / graphql-engine:8080 {
        websocket
    }
}

Then, that's what I have in my docker-compose:

caddy:
    image: the-image-I-built:latest
    depends_on:
      - "graphql-engine"
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - caddy_certs:/root/.caddy

But then the container is always restarting:

CONTAINER ID        IMAGE                                                                   COMMAND                  CREATED             STATUS                         PORTS               NAMES
25249e479c1a        the-image-I-built:latest    "/bin/parent caddy /…"   36 seconds ago      Restarting (1) 2 seconds ago                       root_caddy_1

And here is the docker logs:

2019/08/17 09:43:37 args:2 - Error during parsing: Unknown directive '/bin/sh'
exit status 1