如何使用 docker-compose 中的 Image WORKDIR 映射卷?
我正在尝试使用
services:
my-app:
image: <image>
volumes:
- ./scripts:./scripts
docker-compose up -d
时,我收到以下错误:Cannot create container for service my-app: invalid volume spec "scripts": invalid volume specification: 'scripts': invalid mount config for type "volume": invalid mount path: 'scripts' mount path must be absolute
scripts
图像的 WORKDIR 中的文件夹而不知道该文件夹在哪里?
最佳答案
不,默认情况下无法做到这一点。但是,如果您愿意,可以使用解决方法
services:
my-app:
image: <image>
volumes:
- ./scripts:/scripts
command: bash -c "ln -s /scripts scripts && orignal command"
docker-compose up -d
docker-compose exec my-app ln -s /scripts scripts
https://stackoverflow.com/questions/46183860/