Mount a volume in docker-compose conditionally

前端 未结 3 865
慢半拍i
慢半拍i 2021-01-07 17:07

I have a docker-compose.yml configuration. In one of the containers there is a Tomcat server and it has some default .war file deployed in we

3条回答
  •  执笔经年
    2021-01-07 17:40

    Instead of (not) mounting a volume commenting out that line, I would use https://docs.docker.com/compose/extends/#example-use-case to run a service extension that specifies a volume.

    I do this to tackle two different problems:

    • I don't specify a volume when the docker image is meant to run in production and has all the necessary files bundled in it.
    • I specify a volume during development, to check live changes.

提交回复
热议问题