dockerfile.yml

2023-11-07

通过 [[Docker Compose]] 构建和运行 [[Dockerfile]],下面的文件以 [[python-pip]] 为例:

version: "3.9"
services:
myapp:
build:
context: ./
dockerfile: ./Dockerfile
container_name: myapp
image: myapp:latest
volumes:
- /data:/data
ports:
- 80:5000
restart: unless-stopped
volumes:
data:

执行:docker-compose up -d --build 时,会自动删除旧的容器,但镜像需要手动进行删除(可使用 [[Docker/image]] 命令进行统一删除)。