I want to perform the dump of a remote (not on local machine) mariadb database locally using a container created with the official mariadb image. The final goal is to import the remote database into the container to serve it on localhost.
Unfortunately I'm having trouble connecting to the external IP where the remote database is located from inside the Docker container. I can do that from outside the docker container.
I've created the container like this
docker run --name mariadb -p 3308:3306 -p 443:443 \ -e MYSQL_ROOT_PASSWORD=password1 \ -e MYSQL_DATABASE=test_database \ --add-host internal-host:remote_host_where_db_is_located \ -d mariadb:latest Note that I added a redirect for port 443 and a host linked to the address where the database is located.
Then I tried to do
docker exec -i mariadb mariadb-dump --user=remote_user \ --host=internal-host \ --port=443 --password=remote_password --all-databases > dump.sql This just hangs and nothing is produced, and I don't get any error...which is confusing.
Tried to just connect to the database from inside the container shell
mariadb --user=remote_user \ --host=internal-host --port=443 \ --password=remote_password remote_database_name but this obviously also hangs.
--add-host, i.e.remote_host_where_db_is_located?telnetwhich should print some output that includes the server version if the server ends up responding and sending the handshake to the client. If you receive nothing, it's most likely not related to MariaDB but something in either the container system or the network.docker exec -ti name_of_my_container bash -c 'apt update && apt -y install iputils-ping telnet'.