With limited MySQL knowledge I started digging deeper. Following was the thought process -
1) Can the backup be copied inside a container running MySQL image?
2) That would require a volume store in VCH which can be mounted inside the MySQL container.
3) Test if the database is restored and running - locally as well as using a remote client.
Lets dive into how this was done using vSphere Integrated Containers.
I have already deployed the VCH.
Lets create a volume store where the DB Backup can be copied.
Next create and mount the volume in a MySQL container.
-v: Bind mount a volume. soure_volume:container_destination_options
-e: The environment variable.
MYSQL_ROOT_PASSWORD: Password option is mandatory when running a MySQL container. You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD or MYSQL_RANDOM_ROOT_PASSWORD
Refer to "How to use this image" in the official repository
--network: connecting the container to a container network defined while creating the VCH. This was defined with a IP block so it will assign an IP from that block.
mysql: image name.
Now that the container is created, lets copy the mysql_db_dump.sql dump file to the volume that is mounted to the container.
Now that the database dump is copied in the container, lets start it. Once that container is running lets confirm if the dump file is copied at /var/lib/mysql
Next, lets check what databases are currently running inside the container. There are multiple ways you can achieve this -
Opening a bash shell to the container:
As you can see we land directly at the root prompt inside the container.
mysql -uroot -pversecurepassword
Login to mysql with root as the username and verysecurepassword as the password. The password was set at the time of container creation.
This gives you a mysql prompt. From here you can run all your queries against the Database.
Using Docker exec:
You can also use docker exec -i to just pass commands to the container in an interactive mode instead of the Bash shell. Here is how its done -
As you can see the database has been restored and "show tables;" lists all tables.
Lets create a client container to see if we can connect to the Database from it.
This concludes that we can connect to the restored database locally as well as from a remote client.