docker: mysql: docker-compose.yml setup

In this quick guide we show how to get a docker mysql running quickly that other docker containers can connect to.

docker: mysql: docker-compose.yml setup
Photo by Rubaitul Azad / Unsplash

If you need a quick mysql that stuff can connect to -create a new folder and inside it create a file named docker-compose.yml and put the following in it.  If you need to install docker/docker-compose a quick script is here:

Note: version '2.0' is now obsoleted.

version: '2.1'

    image: mysql:8.0
    restart: always
      - 3306:3306
      - ./mysql:/var/lib/mysql
      MYSQL_ROOT_PASSWORD: 'somepassword'

To check that it ran properly:

docker-compose up

To run permanently in daemon mode:

docker-compose up -d
Linux Rocks Every Day