Hello,
The compose file is as follows:
portal:
container_name: portal
restart: unless-stopped
build:
context: /home/docker/portal
dockerfile: Dockerfile
entrypoint: ["/usr/local/bin/entrypoint.sh"]
command: ["php-fpm"]
networks:
app_network: {}
host_network:
aliases:
- portal.host
environment:
APP_ENV: local
DB_HOST: host.docker.internal
DB_PORT: 3306
DB_DATABASE: laravel
DB_USERNAME: root
DB_PASSWORD: 123456
USER_ID: ${USER_ID:-999}
GROUP_ID: ${GROUP_ID:-995}
volumes:
- /home/docker/portal:/var/www
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
app_network:
driver: bridge
host_network:
external: true
name: host_net
I want the portal container to simultaneously use the internal network to communicate with other containers and the external network to communicate with the host. The MariaDB is running on IP 0.0.0.0
and port 3306
on the host.
I logged into the portal container,
but I can’t see MariaDB on the host:
$ nc 172.20.2.58 -v 3306
Ncat: Version 7.93 ( https://nmap.org/ncat )
Ncat: No route to host.
You may blame me for doing this or find it strange, but I have to do this for a number of reasons.
Thank you.