您也可以放弃Dockerfile,因为它很简单,只需使用一个基本图像并在compose文件中指定命令:
version: '3.2'
services:
frontend:
image: node:12-alpine
volumes:
- ./frontend/:/app/
command: sh -c "cd /app/ && yarn && yarn run start"
expose: [8080]
ports:
- 8080:4200
这对我来说特别有用,因为我只需要图像的环境,但在容器外操作我的文件,我认为这也是你想要做的。