Giter Site home page Giter Site logo

kisevu / docker-mysql-spring-boot-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from techprimers/docker-mysql-spring-boot-example

0.0 0.0 0.0 57 KB

Spring Boot on Docker connecting to MySQL Docker container

Shell 38.15% Java 32.40% Batchfile 29.45%

docker-mysql-spring-boot-example's Introduction

Spring Boot on Docker connecting to MySQL Docker container

  1. 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

  2. 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

  3. 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"]

  4. Using the Dockerfile create the Docker image. From the directory of Dockerfile - docker build . -t users-mysql

  5. Run the Docker image (users-mysql) created in #4. docker build . -t users-mysql

Useful Docker commands

  • docker images
  • docker container ls
  • docker logs <container_name>
  • docker container rm <container_name
  • docker image rm <image_name

docker-mysql-spring-boot-example's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.