Y
Y
Yaroslav2018-12-29 00:00:25
MySQL
Yaroslav, 2018-12-29 00:00:25

How to get from a docker container to a remote Mysql host?

nginx+php+mysql containers are deployed, the site works fine on them, but when trying to connect to a remote database, an error occurs

[email protected]:/# mysql -u user -p*** -h 192.168.58.233
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.58.233' (111)

Connects from another machine on the same network without problems (no docker). Ports mapped
mysql:
        build: ./mysql
        container_name: mysql
        volumes_from:
            - source
        ports:
            - '${INTERFACE}:3306:3306'
        environment:
            MYSQL_DATABASE: ${MYSQL_DATABASE}
            MYSQL_USER: ${MYSQL_USER}
            MYSQL_PASSWORD: ${MYSQL_PASSWORD}
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
        command: mysqld --sql-mode=""

I have recently studied Docker, do not kick much.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
grinat, 2018-12-29
@grinat

I did not understand the question. But I think here is your answer - refer to the name of the container, in this case it is mysql, i.e. if you type mysql:3306 inside the machines, then connect to mysql, nginx - nginx will open, remove ports, there is no point in forwarding them outside

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question