pull image mysql và phpmyadmin
docker pull mysql:latest docker pull phpmyadmin:latest
Tạo network mysql
docker network create mysql
Tạo thư mục mysql, trong thư mục này tạo file docker-compose.yml với nội dung:
version: "3.8" services: mysql: image: mysql:latest restart: unless-stopped volumes: - .docker/mysql_data:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=tuong1234 container_name: tuong_mysql networks: - mysql phpmyadmin: image: phpmyadmin/phpmyadmin:latest restart: unless-stopped ports: - 8081:80 environment: - PMA_HOST=tuong_mysql:3306 container_name: myphpadmin depends_on: - mysql networks: - mysql networks: mysql: external: true
Run:
docker-compose up -d
Xem log:
docker-compose logs -f