mysql 8 socket docker compose windows code example

Example 1: mysql 8 socket docker compose windows

#For docker-compose on windows you'll need to use a docker volume due to fs issues rather than a bind mount as per the following
version: '3.9'
services:

  php:
    image: docker-dev
    build:
      context: .
      dockerfile: ./Dockerfile
    ports:
      - "80:80"
    volumes:
      - "./../code/htdocs:/var/www/html:rw"
    links:
      - db
  
  db:
    image: mysql:8.0.22
    command: --default-authentication-plugin=mysql_native_password
    ports:
      - "3306:3306"
    environment:
      MYSQL_USER: docker
      MYSQL_PASSWORD: docker
      MYSQL_ROOT_PASSWORD: example
    volumes:
      - dev-db:/var/lib/mysql
volumes:
  dev-db:

Example 2: set mysql socket file docker windows

# For docker run adding this should work theoretically - 
--socket=/tmp/mysql.sock

# In practice you'll probably need to look at mounting a docker volume
# and using that

Tags:

Misc Example