Migrating mySQL DB From Ubuntu Host to Docker
Hey Guys -
Recently I set up an Atomic Docker Host (Fedora-based) in my home lab. My plan is to migrate many service applications that I have spread out to it which should give me some base experience with Docker and such. One of the first things I'm trying to do is migrate a mySQL Database over.
I have a mySQL 5.7.21 Database running on an Ubunutu system which I use for my home's Kodi library. I've found that it seems simple to move a database to another server by dumping it, copying, then importing it; I just am not sure how to do that with a mysql Docker Container.
I've already pulled the image by executing "docker pull mysql" on my Docker host, but am not 100% sure how to proceed beyond that to get the DB imported. Below is what I think I need to do - could someone please verify and correct if needed?
1. Pull the mySQL Docker image (done)
2. Start a new mysql instance by executing something like "docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag"
3. Copy the database from the Ubuntu host to a path on the Atomic (Docker) host using SCP
4. Import the new database.
I see that the mysql command to import it would be something like
"mysql -u root -p newdatabase < /path/to/newdatabase.sql"
but I'm not sure the best way to go about it with Docker. It seems that I can create a new container to run mySQL command line by executing something like "docker run -it --link some-mysql:mysql --rm mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'"
but not sure it's the best way to go about it. If so, how would I reference the file(s) I copied over to the Docker host for import?
Any help would be greatly appreciated - Thanks!
Subject
Written By
Posted
Migrating mySQL DB From Ubuntu Host to Docker
April 13, 2018 11:41AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.