Docker Compose MySQL

Project image

Published: 2 January 2021

  1. Docker desktop configured on the machine.

Docker enables us to separate applications from infrastructure so that we can deliver applications quickly. Today, docker is one of the standards to build and share containerized applications .

Docker helps developers recreate exact copy of development and production environments. Though running a database instance in docker comes with other challenges, this post shows how quick it is to run a mysql database instance using docker compose for development purposes.

This example below is tested on windows 10 with docker desktop version 3.0.0 running on WSL2.

version: "3.4"

    image: mysql:8.0.20
    restart: always
      MYSQL_ROOT_PASSWORD: strongpassword!
      MYSQL_USER: usermysql
      MYSQL_PASSWORD: strongdbpassword!
      MYSQL_DATABASE: customerdb
      # host : container
      - "33061:3306"
docker-compose up

We have seen a mysql instance running as as docker image using compose file. To move this in production learn more about volumes for data persistence .

Facebook LinkedIn Twitter Github
© Codef5. All Rights Reserved.