- Plesk for Linux
Docker container cannot connect to the external services running outside of the container, on the remote server or Docker host.
Errors could be different based on the specific service, e.g. for MySQL service, it can be:
CONFIG_TEXT: MySQL Connection Error: (2002) No route to host
Services are up and running.
Firewall rejects inbound connections from Docker container.
Configure firewall on the remote server or Docker host to allow connections on the host's specific port from the docker0 interface.
Before configuring firewall, make sure that the host service to be accessed from Docker container
be listening on either IP of interface
In this example, the solution is for allowing Docker container to access MySQL service:
Check the IP address it listens to. It should be like this:
# grep bind-address /etc/my.cnf /etc/mysql/my.cnf
bind-address = 0.0.0.0
If the value of
bind-addressis 127.0.0.1, follow the instructions from this article.
Find the IP address of Docker host:
# ip addr show docker0
inet 192.0.2.2/16 scope global docker0
Next, let's configure the firewall to allow connections on the port 3306 from docker0 interface. Replace 192.0.2.2 with the IP address discovered in the previous step:
# iptables -A INPUT -p tcp -s 192.0.2.2 --dport 3306 -i docker0 -j ACCEPT