Docker Community Forums

Share and learn in the Docker community.

Docker network_mode: host connect to 10.x.x.x ip outside

I have a problem with connection to db; unfortunately I can change anything only for docker, I cant change any of ip on server.

I have a server, it have mysql server(localhost - 127.0.0.1) and mysql server from hosting (10.253.x.x). Access to localhost works fine when I use network_mode host but with 10.x I got Can’t connect to server on ‘10.253.x.x’.

my docker-compose file

version: "3"

services:
    admin_web:
        build:
            context: ./
            dockerfile: ./Dockerfile
        container_name: admin_web
        working_dir: /var/www
        volumes:
            - ./../../:/var/www
        restart: unless-stopped
        tty: true
        network_mode: host

How I can connect to second db? Maybe some ip mapping or something.