1

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.

7
  • Have you tried using the real remote host you passed to --add-host, i.e. remote_host_where_db_is_located? Commented Aug 10, 2023 at 13:00
  • Yep, just out of curiosity. Also didn't work :( Commented Aug 10, 2023 at 13:47
  • A common sanity check is to run some command inside the container and make sure it's actually responding correctly. A convenient debug tool for this is telnet which 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. Commented Aug 10, 2023 at 14:52
  • Well, thing is the official mariadb image does not have ping or telnet installed... So it's hard to make any troubleshooting. But what is confusing is that the connection with mariadb does not fail but just hangs Commented Aug 14, 2023 at 12:38
  • If you only need the tools for debugging a single problem, you can install them with docker exec -ti name_of_my_container bash -c 'apt update && apt -y install iputils-ping telnet'. Commented Aug 14, 2023 at 20:31

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.