Simple Caddyfile with Docker compose fails when curling

1. The problem I’m having:

A super simple docker-compose and caddyfile setup will not work when I try to curl it, even though my 2 files are ripped nearly straight from Caddy’s docs and tutorials.

2. Error messages and/or full log output:

This is what I get when I run curl https://localhost (after running docker-compose up --build):

curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

3. Caddy version:

v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=

4. How I installed and ran Caddy:

Caddy is running on a docker container on a fresh Ubuntu 22.04 LTS server.

This is my docker compose:

version: "3.7"

services:
  caddy: 
    image: caddy:latest
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
      - "8443:8443"
      - "8443:8443/udp"
    volumes:
      - $PWD/Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config

And this is my caddyfile:

localhost

respond "Hello, world!"

See here, explained in the docs:

1 Like