1. Caddy version (`2.4.3):
2. How I run Caddy:
I am using 2 different docker-compose projects. The one I want to call via curl uses this configuration: symfony-docker/docker-compose.yml at main · dunglas/symfony-docker · GitHub
I added networks, extra_hosts… nothing worked.
a. System environment:
Docker-compose, Linux Mint 18.
b. Command:
Inside the different docker-compose project, I tried many variations of:
curl api.localost
curl apitest
d. My complete Caddyfile or JSON config:
version: "3.4"
#networks:
services:
php:
# networks:
# - api
container_name: commando_php
build:
context: .
target: symfony_php
args:
SYMFONY_VERSION: ${SYMFONY_VERSION:-}
SKELETON: ${SKELETON:-symfony/skeleton}
STABILITY: ${STABILITY:-stable}
restart: unless-stopped
volumes:
- php_socket:/var/run/php
healthcheck:
interval: 10s
timeout: 3s
retries: 3
start_period: 30s
environment:
# Run "composer require symfony/orm-pack" to install and configure Doctrine ORM
DATABASE_URL: postgresql://${POSTGRES_USER:-symfony}:${POSTGRES_PASSWORD:-ChangeMe}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-13}
# Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration
MERCURE_URL: ${CADDY_MERCURE_URL:-http://caddy/.well-known/mercure}
MERCURE_PUBLIC_URL: https://${SERVER_NAME:-localhost}/.well-known/mercure
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeMe!}
caddy:
# networks:
# - api
# networks:
# api:
# aliases:
# - php.dock
container_name: commando_caddy
build:
network: host
context: .
target: symfony_caddy
depends_on:
- php
environment:
SERVER_NAME: ${SERVER_NAME:-localhost, caddy:80}
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeMe!}
MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeMe!}
restart: unless-stopped
volumes:
- php_socket:/var/run/php
- caddy_data:/data
- caddy_config:/config
ports:
# HTTP
- target: 80
published: 80
protocol: tcp
# HTTPS
- target: 443
published: 443
protocol: tcp
# HTTP/3
- target: 443
published: 443
protocol: udp
extra_hosts:
- "host.docker.internal:host-gateway"
- "apitest:host-gateway"
###> doctrine/doctrine-bundle docker pull postgis/postgis:13-3.1-alpine ###
database:
image: postgis/postgis:13-3.1-alpine
environment:
POSTGRES_DB: ${POSTGRES_DB:-app}
# You should definitely change the password in production
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-ChangeMe}
POSTGRES_USER: ${POSTGRES_USER:-symfony}
volumes:
- db-data:/var/lib/postgresql/data:rw
# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
# - ./docker/db/data:/var/lib/postgresql/data:rw
###< doctrine/doctrine-bundle ###
volumes:
php_socket:
caddy_data:
caddy_config:
###> doctrine/doctrine-bundle ###
db-data:
###< doctrine/doctrine-bundle ###
3. The problem I’m having:
Docker-compose works perfect when I run it with SERVER_NAME="api.localhost:80" docker-compose up -d --build
.
But completely isolated project having its own docker-compose, doesn’t see it at all. The best I got was empty response when I curl-ed to IP address I found via inspect.
4. Error messages and/or full log output:
There are none. The only response I get is this when I curl -i 192.168.112.4
:
HTTP/1.1 200 OK
Server: Caddy
Date: Mon, 26 Jul 2021 11:03:23 GMT
Content-Length: 0
5. What I already tried:
I have been trying to solve this problem for last 3-4 days, nothing worked. I am absolute Docker+caddy noob, my first time of using them and so far, probably tried about 100 different combinations.
Most recommendations are to use host.docker.internal:host-gateway but that didn’t work either; although I use latest docker and it should work on Linux.
6. Links to relevant resources:
Most of stackoverflow answers are telling to use network in docker-compose, but none worked.
Just for reference: this is 100% for my local development, not production.