How to mount a single file in a volume

后端 未结 14 1058
隐瞒了意图╮
隐瞒了意图╮ 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:40

    In windows, if you need the a ${PWD} env variable in your docker-compose.yml you can creat a .env file in the same directory as your docker-compose.yml file then insert manualy the location of your folder.

    CMD (pwd_var.bat) :

    echo PWD=%cd% >> .env
    

    Powershell (pwd_var.ps1) :

    $PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'; echo "PWD=$(get-location).path" >> .env
    

    There is more good features hear for docker-compose .env variables: https://docs.docker.com/compose/reference/envvars/ especially for the COMPOSE_CONVERT_WINDOWS_PATHS env variable that allow docker compose to accept windows path with baskslash "\".

    When you want to share a file on windows, the file must exist before sharing it with the container.

提交回复
热议问题