Setup caddy with docker on local machine

1. Caddy version (latest):

2. How I run Caddy:

In docker on local machine

a. System environment:

windows 10 wsl2

b. Command:


c. docker.compose file:

    image: caddy:latest
    restart: unless-stopped
      - "80:80"
      - "443:443"
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./site:/srv
      - caddy_data:/data
      - caddy_config:/config

d. My complete Caddyfile


respond "hello world"

3. The problem I’m having:

I’d like to get a simple hello world example going.
Entering https://localhost in the browser
will only show “This site can not be reached”

1 Like

I’ve seen in the past that WSL has trouble being mapped to localhost on the host machine. This issue might be relevant:

Also, note that when running in Docker, Caddy can’t install the root CA cert it generates to your system trust stores, because it’s isolated from the rest of your system. So you’ll likely need to extract the certificate from the container to do so. It should be found in /data/pki/authorities/local/root.crt inside the container.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.