Search code examples
dockerdocker-composepermission-deniedcaddycaddyfile

How to run Caddy from Docker container? (443 bind: permission denied)


As you would asume, I'm just starting to work with Docker and Caddy but I'm haven't being able to run it since I'm getting the following error:

Could not start HTTPS server for challenge -> listen tcp :443: bind: permission denied

Here is the docker-compose.yml:

webserver:
    image: jumanjiman/caddy
    depends_on:
      - parse-dashboard
      - loovus
    ports:
      - "80:8000"
      - "443:443"
    links:
      - parse-dashboard
      - parse-server
    volumes:
      - ./production:/prod/
      - ./dist/:/angular/
    command: -port 8000 -host 0.0.0.0 -conf /prod/Caddyfile

Here is the Caddyfile:

qa.loovus.mx:8000

tls [email protected]

gzip {
ext .js .css
}

root /angular

proxy /parse parse-server:1337

rewrite / {
if {path} not_match /parse
to {path} /index.html
}

If you can give me any hint, I would really appreciate it.

Thank you in advance!


Solution

  • After struggling with this matter for so long, I got the right configuration. Here is what I did:

    • Use abiosoft/caddy
    • Left the default ports (80 and 443)
    • Modify the docker-compose file to use this command:

    command: -conf /prod/Caddyfile

    Because apparently I was overriding the Caddyfile configuration by using the previous command:

    command: -port 8000 -host 0.0.0.0 -conf /prod/Caddyfile

    Using these modifications I was able to run HTTPS on my website.

    Thank you