Docker-compose, conditional statements? (e.g. add volume only if condition)

后端 未结 6 1686
野趣味
野趣味 2021-02-12 02:25

I want to add a volume to my service, but only if the final user gave a folder for it. Otherwise, no volume should be mounted, for the already-prepared image has valid data in a

6条回答
  •  无人共我
    2021-02-12 03:11

    Poor man's solution:

        volumes:
          ${VARIABLE:-/dev/null}:/app/folder
    

    Or:

        volumes:
          ${VARIABLE:-/dev/null}:${VARIABLE:-/tmp}/app/folder
    

提交回复
热议问题