How to mount a single file in a volume

后端 未结 14 1118
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 10:16

I am trying to dockerize a PHP application. In the dockerfile, I download the archive, extract it, etc.

Everything works fine. However, if a new version gets released

14条回答
  •  情书的邮戳
    2020-11-27 10:36

    TL;DR/Notice:

    If you experience a directory being created in place of the file you are trying to mount, you have probably failed to supply a valid and absolute path. This is a common mistake with a silent and confusing failure mode.

    File volumes are done this way in docker (absolute path example (can use env variables), and you need to mention the file name) :

        volumes:
          - /src/docker/myapp/upload:/var/www/html/upload
          - /src/docker/myapp/upload/config.php:/var/www/html/config.php
    

    You can also do:

        volumes:
          - ${PWD}/upload:/var/www/html/upload
          - ${PWD}/upload/config.php:/var/www/html/config.php
    

    If you fire the docker-compose from /src/docker/myapp folder

提交回复
热议问题