(1) Create docker-compose.yml
docker-compose.yml
version: "3.8"
services:
db:
image: mysql:5.7 #Specify the version of mysql
container_name: docker_mysql
ports:
- "3307:3306" #Specify the port to start DB
environment:
- MYSQL_USER=root
- MYSQL_PASSWORD=
- MYSQL_ROOT_PASSWORD=
- MYSQL_ALLOW_EMPTY_PASSWORD=yes #Allow no password
volumes:
- mysql-db-data:/var/lib/mysql #Data persistence
tty: true #Keep starting the container
volumes:
mysql-db-data:
driver: local
(2) Start mysql docker-compose up -d
(3) Connect to mysql mysql -u root -h 127.0.0.1 -P 3307
Recommended Posts