Subscribe to Posts by Email

Subscriber Count

    696

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

Docker : Oracle MySQL Container

 

Assuming you have completed docker installation on windows and registered with oracle container registry, Read first part here if not yet done

This post explain how to create a container for mysql and also show some example of managing container etc. In less than 10 mins mysql database is ready and you can practice what ever you like.

Pull Docker Image and Run the docker with default  options

docker pull container-registry.oracle.com/mysql/community-server

Run the docker with mysql image, I have kept the root password and name of docker is mysql5.7

docker run --name mysql5.7 -e MYSQL_ROOT_PASSWORD=sayit -d container-registry.oracle.com/mysql/community-server:lates

Login to Shell

docker exec -it mysql5.7 bash

mysql1 mysql2 mysql3 mysql4

Getting connected outside from the docker use -p or -P option while run the docker command

 

Once logged in , show databases and create databases etc and rest of things will be as usual.

mysql7

 

Stop docker container

docker stop mysql5.7

mysql5

Start docker container

docker start mysql5.7

mysql6

 

Remove docker container, you can use -f option to forcefully delete the running docker

docker rm mysql5.6 -f 

 

Further, if you want to keep any additional parameter you can use a cnf file and run the docker run command, this file will replace the cnf file in the docker container 🙂

The MySQL startup configuration in these Docker images is specified in the file /etc/my.cnf. If you want to customize this configuration for your own purposes, you can create your alternative configuration file in a directory on the host machine and then mount this file in the appropriate location inside the MySQL container, effectively replacing the standard configuration file.

If you want to base your changes on the standard configuration file, start your MySQL container in the standard way described above, then do:
docker exec -it my-container-name cat /etc/my.cnf > /my/custom/config-file
… where ´/my/custom/config-file´ is the path and name of the new configuration file. Then start a new MySQL container like this:
docker run --name my-new-container-name -v /my/custom/config-file:/etc/my.cnf -e MYSQL_ROOT_PASSWORD=my-secret-pw -d container-registry.oracle.com/mysql/community-server:tag

 

Comments are closed.