My Tinkering space for Learning Backend using Spring !
- Clone the Project
- Setup mysql container first by pulling the image
docker pull mysql:5.6
then running the container usingdocker run --name mysql-db -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=test -e MYSQL_USER=regular -e MYSQL_PASSWORD=root -d mysql:5.6
- Make sure the same credentials are setup in the
resources/application.properties
file - Build the jar file by running
mvn clean package
- Create a Docker container with the jar file by running
docker build . -t restapi
- Run the created container and link it to the already running sql container running
docker run -p 8080:8080 --name restapi --link mysql-db:mysql -d restapi
- It should run. If not Happy debugging :/
- Build the jar file again
mvn clean package
- Build the docker image again
docker build . -t restapi
- Simply run the container again, the DB container should always be running.