Dump a remote database locally using mariadb docker container

221 Views Asked by At

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.

0

There are 0 best solutions below