Since this is the first time for me to use spring-boot project running in the docker with MySQL database, I use a lot of Yuan Ji’s work for reference， you can also read his web page directly.
In the learning of this project, I have met with many difficulties. To help others have a better understanding of spring-mysql running on the docker. I decide to write it down and you can find the demo project at GitHub.
- -name demo-mysql to assign a name to the container.
- -e to pass environment variables to the container, and create a demo database with a user demo-user and password. This user will be granted superuser permissions for the demo database.
- -p 3306:3306 to expose MySQL port to the local host.
- -d to tell Docker to daemonize the container and keep it running.mysql:5.6 to download MySQL 5.6 Server image from Docker public repo if not in your computer yet.
And you can access the server by localhost:3307/demo,the database instance is “demo”, the user is “demo_user” and the password is “demo_pass”.
This is the end!