Use Docker Compose to start MySQL

I had a slight issue, of how to start MySQL server by using Docker Compose. So, I came up with the following configuration:

version: '3.7'
services:
  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: 'amazing_database'
      MYSQL_USER: 'root'
      MYSQL_PASSWORD: 'root123'
      MYSQL_ROOT_PASSWORD: 'root123'
    ports:
      - '3306:3306'
    expose:
      - '3306'
    volumes:
      - my-db:/var/lib/mysql

volumes:
  my-db:

Works 🙂

Be First to Comment

Leave a Reply

Your email address will not be published.