Skip to content

KeithLeoSmithIdeam/tutorial-mysql-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Tutorial using MySQL with docker

In this tutorial we will show how easy it is to play with databases using docker

Each verison of MySQL has a different tag or label in docker and these can be found here on Docker Hub

We will also demonstrate the use of Docker Compose see official docs here - https://docs.docker.com/compose/

Pull The image

you must first choose which version you want

docker pull mysql:5.7.30

Review the compose file

Notice we are create a spec that containes two separate docker containers that we want to talk to eachother on an internal private docker network. Notice we do not not need expose any ports on the database side only the database ui as the ui and database will talk on an internal network. If we want to access the database via jdbc we must expose the containers ports

version: '3.1'

services:

  db:
    image: mysql:5.7.30
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    ports:
      - 3307:3306
    environment:
      MYSQL_ROOT_PASSWORD: Password1
      MYSQL_DATABASE: mydatabase
      MYSQL_USER: user1
      MYSQL_PASSWORD: Password1


  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080

Now run the compose file

docker-compose up -d 
docker ps

Test the database using the ui

navigate to http://localhost:8080/ login screen

The database name must match the name of the database service in the compose-file as this becomes like the dns name of the database IP address on the docker internal network

Close eveything

docker-compose down -d 
docker ps

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published