docker 启动mysql 容器
- 拉取mysql镜像
docker pull mysql
- 命令启动
docker run -d -e MYSQL_ROOT_PASSWORD=p --name mysql mysql
- docker-compose 启动
- 编写docker-compose.yml
version: "3" services: mysql-service: image: mysql container_name: mysql environment: - MYSQL_ROOT_PASSWORD=p ports: - "3306:3306"
- 执行命令
docker-compose -f {docker-compose.yml 路径} up -d
- 编写docker-compose.yml