Как связать 2 docker compose локально
Например из php нужно достучаться до бд
Контейнер с бд
networks: proxynet: name: custom_network--
db: container_name: * networks: - proxynet
Контейнер с пхп
networks: my-proxy-net: external: name: custom_network--
php: container_name: * networks: - my-proxy-netзатем
docker inspect custom_networkПолучаем что-то вроде
[ { "Name": "custom_network", "Id": "e5f4a8dc798ca4000975bcf2afc0e1fc177e4969af64f689c923e2503554e3ef", "Created": "2024-12-24T13:17:42.962860439+05:00", "Scope": "local", "Driver": "bridge", "EnableIPv6": false, "IPAM": { "Driver": "default", "Options": null, "Config": [ { "Subnet": "172.20.0.0/16", "Gateway": "172.20.0.1" } ] }, "Internal": false, "Attachable": false, "Ingress": false, "ConfigFrom": { "Network": "" }, "ConfigOnly": false, "Containers": { "b4bff0825d1b9caa8c6819e12c8263a477cde611d54d840886f49d547edf24ac": { "Name": "some_db", "EndpointID": "d96fce9030f91234b56057cf13e5d26d2a16a3e92935656844ed22e96ccaff22", "MacAddress": "02:42:ac:14:00:02", "IPv4Address": "172.20.0.2/16", "IPv6Address": "" } }, "Options": {}, "Labels": { "com.docker.compose.network": "proxynet", "com.docker.compose.project": "docker", "com.docker.compose.version": "2.29.7" } } ]--
Где 172.20.0.1 - хост бд
Комментарии
Отправить комментарий