連結多個 container 方法:
# Terminal 1
docker run --rm -it --name db -e MYSQL_ROOT_PASSWORD=pass -e MYSQL_DATABASE=some percona
# Terminal 2
docker run --rm -it --link db -p 8080:80 phpmyadmin
轉換 docker-compose.yml 應用方法:
services:"3.8"
database:
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: pass
MYSQL_DATABASE: some
MYSQL_USER: some
MYSQL_PASSWORD: your_password_here
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
platform: linux/amd64
ports:
- 8080:80
environment:
- PMA_HOST=database
- MYSQL_ROOT_PASSWORD=pass
- PMA_USER=some
- PMA_PASSWORD=your_password_here
depends_on:
- database
執行指令與說明:
# 直接背景執行,當中斷的時候,會停止所有 container、GIF 範例使用下面的指令
docker-compose up
# 背景執行
docker-compose up -d
# 查看 log
docker-compose logs -f