Use MySQL Image published by Docker Hub (https://hub.docker.com/_/mysql/)
Command to run the mysql container
docker run --name mysql-standalone -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=test -e MYSQL_USER=sa -e MYSQL_PASSWORD=password -d mysql:5.6
In the Spring Boot Application, use the same container name of the mysql instance in the application.properties
spring.datasource.url = jdbc:mysql://mysql-standalone:3306/test
Create a Dockerfile for creating a docker image from the Spring Boot Application
FROM openjdk:8 ADD target/users-mysql.jar users-mysql.jar EXPOSE 8086 ENTRYPOINT ["java", "-jar", "users-mysql.jar"]
Using the Dockerfile create the Docker image.
From the directory of Dockerfile - docker build . -t users-mysql
Run the Docker image (users-mysql) created in #4.
docker build . -t users-mysql
docker imagesdocker container lsdocker logs <container_name>docker container rm <container_namedocker image rm <image_nameContent type
Image
Digest
Size
233.5 MB
Last updated
almost 7 years ago
docker pull kebonce40/docker-test