Service phpyMyAdmin can't connect to db (connection refused). But as soon as I add the the same networks (default and traefik) to the db service, it starts working.
Why? For what I understand right now both share the same implicit default network. Ideed:
[
{
"Name": "wikiiosystemsit_default",
"Id": "62eab0cee810c380c3b494f9a7fa4db9ed485ea002d70de4cb2fcfb7ea94f84c",
"Created": "2024-12-12T23:49:31.56548723Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.19.0.0/16",
"Gateway": "172.19.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"4276e2b6bdc18f45d475ede7408feb79fe542205b23cc0ec36a61db88c3a2f90": {
"Name": "wikiiosystemsit-phpmyadmin",
"EndpointID": "9c73dbf36dfcd5492bd418b5288e00b6ad57b2a29ea6bf07fed1cc427e47ff89",
"MacAddress": "02:42:ac:13:00:03",
"IPv4Address": "172.19.0.3/16",
"IPv6Address": ""
},
"d9a61504b1c97fd6fee155d61b1fa08cf0b62ba7261659a8d96f3f21ba015390": {
"Name": "wikiiosystemsit-db",
"EndpointID": "228d54ab65734bb3283ec6018e5c321846d59cf5c9bf9637e23dd3719d7749ee",
"MacAddress": "02:42:ac:13:00:02",
"IPv4Address": "172.19.0.2/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.config-hash": "968eb6d395e1f23e415b8a7f99cc736629616b1cf3cc507ca678097b776fb609",
"com.docker.compose.network": "default",
"com.docker.compose.project": "wikiiosystemsit",
"com.docker.compose.version": "2.31.0"
}
}
]
My Compose file:
services:
db:
container_name: ${COMPOSE_PROJECT_NAME}-db
image: mariadb:11
volumes:
- db-data:/var/lib/mysql
environment:
MARIADB_USER: ${DATABASE_USER:?}
MARIADB_PASSWORD: ${DATABASE_PASSWORD:?}
MARIADB_DATABASE: ${DATABASE_NAME:?}
MARIADB_ROOT_PASSWORD: ${DATABASE_ROOT_PASSWORD:?}
TZ: ${TZ:-Europe/Rome}
# Uncomment and this will work
#networks:
# - default
# - traefik
restart: unless-stopped
phpmyadmin:
container_name: ${COMPOSE_PROJECT_NAME}-phpmyadmin
image: phpmyadmin:latest
environment:
PMA_ARBITRARY: true
PMA_HOST: db
UPLOAD_LIMIT: 10M
TZ: ${TZ:-Europe/Rome}
networks:
- default
- traefik
restart: unless-stopped
volumes:
db-data:
networks:
traefik:
external: true
MARIADB_USERandMARIADB_PASSWORD.docker container inspectfor all the containers,docker network inspectfor the default network, and the output fromdocker compose up.