5/30 TIL: mysql Docker image, Unix Domain Socket

davidhwangij

David Hwang

Posted on May 31, 2021

5/30 TIL: mysql Docker image, Unix Domain Socket

Docker Compose

  • Do a 'docker-compose -f nameOfYourDockerComposeFile build' if you need your changes in Dockerfile to be reflected—because simply doing 'docker-compose up' doesn't rebuild an image

Docker mysql image

  • Configuration options can be passed as flags in the command line. Ex) --character-set-server=utf8mb4
  • When a mysql container is started for the first time, it will execute files with extensions .sh, .sql and .sql.gz that are found in /docker-entrypoint-initdb.d. So we can populate our mysql services by mounting a SQL dump into that directory. In our example below, we would store our .sql files in db/init and mount it to /docker-entrypoint-initdb.d under volumes:
services:
  db:
    container_name: mysql
    image: mysql
    restart: always
    environment:
      MYSQL_USER: user1
      MYSQL_PASSWORD: test
      MYSQL_ROOT_PASSWORD: test
      MYSQL_DATABASE: users
    ports:
      - '3306:3306'
    volumes:
      - mysql_db:/var/lib/mysql
      - ./db/init:/docker-entrypoint-initdb.d
    command:
      [
        'mysqld',
        '--character-set-server=utf8mb4',
        '--collation-server=utf8mb4_unicode_ci',
      ]
volumes:
mysql_db:
Enter fullscreen mode Exit fullscreen mode

Unix Domain Socket

💖 💪 🙅 🚩
davidhwangij
David Hwang

Posted on May 31, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Opposite Colours Tool
codepen Opposite Colours Tool

November 5, 2024

Starting to Rust
rust Starting to Rust

November 4, 2024