Docker Compose的笔记
Visual Studio Code的推荐插件有Docker。
创建Docker Compose用于构建Web API服务器
执行UP命令
docker compose up
运行DOWN命令
docker compose down
执行 UP 命令(重新构建镜像)
docker-compose up –build
docker-compose.yml 文件
version: '3.9'
services:
api:
build: ./api
ports:
-8080:8080
depends_on:
- db
db:
image: postgres:15
port:
- 5432:5432
enviroment:
- POSTGRES_PASSWORD=mypassword
- POSTGRES_USER=postgres
- POSTGRES_DB=appdb
volumes:
- db-storage:/bar/lib/postgresql/data
- ./db/initdb:/docker-entrypoint-initdb.d
volumes:
db-storage: