我如何使用图像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有没有办法在图像的WORKDIR中映射我的scripts文件夹,而不知道该文件夹在哪里?
发布于 2017-09-13 09:31:04
不,在默认情况下,没有办法这样做。但是如果你愿意的话,你可以找个解决办法
services:
my-app:
image: <image>
volumes:
- ./scripts:/scripts
command: bash -c "ln -s /scripts scripts && orignal command"但这需要你事先知道命令。所以,要么你在掌握之前就知道命令,要么在掌握之前就知道WORKDIR。
您还可以将工作目录更改为任何其他需要的目录。如果您不想重写该命令,则另一个可能的选项如下
docker-compose up -d
docker-compose exec my-app ln -s /scripts scriptshttps://stackoverflow.com/questions/46183860
复制相似问题