Reputation: 46218
I'm trying to dump a remote database into a local docker container's database.
$ docker exec -i my_container \
mysqldump my_remote_database -h my_remote_host.me -u my_remote_user -p
This gives me the remote dump well
So here are my attempts:
$ docker exec -i my_container \
mysqldump my_remote_database -h my_remote_host.me -u my_remote_user -p \
| docker exec -i my_container mysql -u my_local_user -pmy_local_password \
-D my_local_database
$ docker exec -i my_container bash -c \
"mysqldump my_remote_database -h my_remote_host.pp -u my_remote_user -p \
| mysql -u my_local_user -pmy_local_password -D my_local_database"
Both don't seem to have any effect on the local database (no error though)
How can I transfer these data ?
Upvotes: 1
Views: 3356
Reputation: 41508
I always like to hammer out problems from inside the container in an interactive terminal.
First, get the cantainer of image running and check to see the following:
docker exec -ti my_container bash
, does the remote hostname my_remote_host.me
resolve and can you route to it? Use ping or nslookup.mydump.sql
dump file.Then check that inside the container:
mysql -u my_local_user -pmy_local_password -D mylocaldb < mydump.sql
If this all works then you can start looking at why the pipe is failing, but I suspect the issue may be with one of the resolutions.
I notice you say local database. Is the 'local database' inside the container or on the Docker host running a socket connection?
Upvotes: 2