Docker compose volume syntax valid for Windows and LinuxWhat are best practices to override complete sections...

How does Mercy remove conditions?

Why is "dyadic" the only word with the prefix "dy-"?

Can you board the plane when your passport is valid less than 3 months?

Biological refrigeration?

Why error propagation in CBC mode encryption affect two blocks?

Thought experiment and possible contradiction between electromagnetism and special relativity

Papers on arXiv solving the same problem at the same time

Why does Windows store Wi-Fi passwords in a reversible format?

Shift lens vs move body?

How were medieval castles built in swamps or marshes without draining them?

Is the internet in Madagascar faster than in UK?

Set orthographic view using python?

Count the number of shortest paths to n

Half filled water bottle

Open subspaces of CW complexes

How is linear momentum conserved in case of a freely falling body?

What happened to the HDEV ISS Experiment? Is it over?

Disk usage of integer column vs boolean column in Postgres

What is this fighter jet at Weymouth NAS?

How to prevent a hosting company from accessing a VM's encryption keys?

Why does a sticker slowly peel off, but if it is pulled quickly it tears?

To what extent should we fear giving offense?

Can I renew my USA passport book and passport card separately?

Contours of a national emergency in the United States



Docker compose volume syntax valid for Windows and Linux


What are best practices to override complete sections using docker-compose?Unable to mount docker folder into host using docker-composeDoes Docker allow containers to be OS agnostic?Windows Docker in swarm with Linux nodes connection issueJoin a Linux Docker swarm with a local Windows Docker for test purposesHow to assign static ip in docker for Windows for linux container?How to deploy my Express/React app to server with docker-compose and DockerfilesVolumes Not Mounting with Docker-Compose






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















We have developers working on an app using both Windows and Linux. The application is built within a Docker container, and ships a docker-compose specification for the build environment.



The local directory is mounted as a volume:



    volumes:
- ${PWD}:/tmp


however this doesn't work in Windows because $PWD is not defined.



My question is:



Can we have a single docker-compose.yml to satisfy both the Windows and Linux developers?



The obvious way to do this seems to me to have two docker-compose files, one for each OS.










share|improve this question

































    1















    We have developers working on an app using both Windows and Linux. The application is built within a Docker container, and ships a docker-compose specification for the build environment.



    The local directory is mounted as a volume:



        volumes:
    - ${PWD}:/tmp


    however this doesn't work in Windows because $PWD is not defined.



    My question is:



    Can we have a single docker-compose.yml to satisfy both the Windows and Linux developers?



    The obvious way to do this seems to me to have two docker-compose files, one for each OS.










    share|improve this question





























      1












      1








      1








      We have developers working on an app using both Windows and Linux. The application is built within a Docker container, and ships a docker-compose specification for the build environment.



      The local directory is mounted as a volume:



          volumes:
      - ${PWD}:/tmp


      however this doesn't work in Windows because $PWD is not defined.



      My question is:



      Can we have a single docker-compose.yml to satisfy both the Windows and Linux developers?



      The obvious way to do this seems to me to have two docker-compose files, one for each OS.










      share|improve this question
















      We have developers working on an app using both Windows and Linux. The application is built within a Docker container, and ships a docker-compose specification for the build environment.



      The local directory is mounted as a volume:



          volumes:
      - ${PWD}:/tmp


      however this doesn't work in Windows because $PWD is not defined.



      My question is:



      Can we have a single docker-compose.yml to satisfy both the Windows and Linux developers?



      The obvious way to do this seems to me to have two docker-compose files, one for each OS.







      docker-compose linux windows environment-variables volume






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 8 hours ago









      Gaius

      7933 silver badges13 bronze badges




      7933 silver badges13 bronze badges










      asked 10 hours ago









      Bruce BeckerBruce Becker

      7854 silver badges24 bronze badges




      7854 silver badges24 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          1















          Yes. Just use ./ for you current directory that the Docker-compose file is in. Docker-Compose does not allow you to use a context that is located above the compose file, so everything the compose file will use is below the folder with the .yml. Your "working directory" for the compose file is just "./". If you are trying to set a directory below that it would look something like:


          volumes:
          - ./DirectoryIWantToTarget:/tmp


          There's an example of this in the Docker-Compose documentation here. This approach makes the solution cross-platform as well.






          share|improve this answer

































            1















            PS C:Usersgaius> Write-Output $PSVersionTable.PSVersion

            Major Minor Build Revision
            ----- ----- ----- --------
            5 1 17763 592



            PS C:Usersgaius> Write-Output $pwd

            Path
            ----
            C:Usersgaius


            That appears to work as expected, what versions of things are you using?



            Compare to Linux:



            gaius@klossy:~$ pwsh
            PowerShell 6.2.2
            Copyright (c) Microsoft Corporation. All rights reserved.

            https://aka.ms/pscore6-docs
            Type 'help' to get help.

            PS /home/gaius> echo $pwd

            Path
            ----
            /home/gaius

            PS /home/gaius>


            (echo is just an alias for Write-Output)



            If you must have exact commonality between Windows and Linux there are a few solutions, Git comes with Bash for Windows, there's WSL, etc.






            share|improve this answer























            • 1





              This answer makes me look like a bit of an idiot :) -- and certainly show the gaps in my PowerShell knowledge. The developer claimed that ${PWD} wasn't working for them Unfortunately, I have no way of verifying this, not having access to a Windows machine. But certainly it looks like it should work (I'm using Powershell 6.2.2 on Linux)

              – Bruce Becker
              8 hours ago






            • 1





              @BruceBecker added the Linux to my answer

              – Gaius
              7 hours ago











            • Actually now that I think about it some more, just recommend your Windows devs use Git Bash if they absolutely must do things the same way as Linux

              – Gaius
              7 hours ago














            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "674"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdevops.stackexchange.com%2fquestions%2f9002%2fdocker-compose-volume-syntax-valid-for-windows-and-linux%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1















            Yes. Just use ./ for you current directory that the Docker-compose file is in. Docker-Compose does not allow you to use a context that is located above the compose file, so everything the compose file will use is below the folder with the .yml. Your "working directory" for the compose file is just "./". If you are trying to set a directory below that it would look something like:


            volumes:
            - ./DirectoryIWantToTarget:/tmp


            There's an example of this in the Docker-Compose documentation here. This approach makes the solution cross-platform as well.






            share|improve this answer






























              1















              Yes. Just use ./ for you current directory that the Docker-compose file is in. Docker-Compose does not allow you to use a context that is located above the compose file, so everything the compose file will use is below the folder with the .yml. Your "working directory" for the compose file is just "./". If you are trying to set a directory below that it would look something like:


              volumes:
              - ./DirectoryIWantToTarget:/tmp


              There's an example of this in the Docker-Compose documentation here. This approach makes the solution cross-platform as well.






              share|improve this answer




























                1














                1










                1









                Yes. Just use ./ for you current directory that the Docker-compose file is in. Docker-Compose does not allow you to use a context that is located above the compose file, so everything the compose file will use is below the folder with the .yml. Your "working directory" for the compose file is just "./". If you are trying to set a directory below that it would look something like:


                volumes:
                - ./DirectoryIWantToTarget:/tmp


                There's an example of this in the Docker-Compose documentation here. This approach makes the solution cross-platform as well.






                share|improve this answer













                Yes. Just use ./ for you current directory that the Docker-compose file is in. Docker-Compose does not allow you to use a context that is located above the compose file, so everything the compose file will use is below the folder with the .yml. Your "working directory" for the compose file is just "./". If you are trying to set a directory below that it would look something like:


                volumes:
                - ./DirectoryIWantToTarget:/tmp


                There's an example of this in the Docker-Compose documentation here. This approach makes the solution cross-platform as well.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 9 hours ago









                Wesley RolnickWesley Rolnick

                3405 bronze badges




                3405 bronze badges




























                    1















                    PS C:Usersgaius> Write-Output $PSVersionTable.PSVersion

                    Major Minor Build Revision
                    ----- ----- ----- --------
                    5 1 17763 592



                    PS C:Usersgaius> Write-Output $pwd

                    Path
                    ----
                    C:Usersgaius


                    That appears to work as expected, what versions of things are you using?



                    Compare to Linux:



                    gaius@klossy:~$ pwsh
                    PowerShell 6.2.2
                    Copyright (c) Microsoft Corporation. All rights reserved.

                    https://aka.ms/pscore6-docs
                    Type 'help' to get help.

                    PS /home/gaius> echo $pwd

                    Path
                    ----
                    /home/gaius

                    PS /home/gaius>


                    (echo is just an alias for Write-Output)



                    If you must have exact commonality between Windows and Linux there are a few solutions, Git comes with Bash for Windows, there's WSL, etc.






                    share|improve this answer























                    • 1





                      This answer makes me look like a bit of an idiot :) -- and certainly show the gaps in my PowerShell knowledge. The developer claimed that ${PWD} wasn't working for them Unfortunately, I have no way of verifying this, not having access to a Windows machine. But certainly it looks like it should work (I'm using Powershell 6.2.2 on Linux)

                      – Bruce Becker
                      8 hours ago






                    • 1





                      @BruceBecker added the Linux to my answer

                      – Gaius
                      7 hours ago











                    • Actually now that I think about it some more, just recommend your Windows devs use Git Bash if they absolutely must do things the same way as Linux

                      – Gaius
                      7 hours ago
















                    1















                    PS C:Usersgaius> Write-Output $PSVersionTable.PSVersion

                    Major Minor Build Revision
                    ----- ----- ----- --------
                    5 1 17763 592



                    PS C:Usersgaius> Write-Output $pwd

                    Path
                    ----
                    C:Usersgaius


                    That appears to work as expected, what versions of things are you using?



                    Compare to Linux:



                    gaius@klossy:~$ pwsh
                    PowerShell 6.2.2
                    Copyright (c) Microsoft Corporation. All rights reserved.

                    https://aka.ms/pscore6-docs
                    Type 'help' to get help.

                    PS /home/gaius> echo $pwd

                    Path
                    ----
                    /home/gaius

                    PS /home/gaius>


                    (echo is just an alias for Write-Output)



                    If you must have exact commonality between Windows and Linux there are a few solutions, Git comes with Bash for Windows, there's WSL, etc.






                    share|improve this answer























                    • 1





                      This answer makes me look like a bit of an idiot :) -- and certainly show the gaps in my PowerShell knowledge. The developer claimed that ${PWD} wasn't working for them Unfortunately, I have no way of verifying this, not having access to a Windows machine. But certainly it looks like it should work (I'm using Powershell 6.2.2 on Linux)

                      – Bruce Becker
                      8 hours ago






                    • 1





                      @BruceBecker added the Linux to my answer

                      – Gaius
                      7 hours ago











                    • Actually now that I think about it some more, just recommend your Windows devs use Git Bash if they absolutely must do things the same way as Linux

                      – Gaius
                      7 hours ago














                    1














                    1










                    1









                    PS C:Usersgaius> Write-Output $PSVersionTable.PSVersion

                    Major Minor Build Revision
                    ----- ----- ----- --------
                    5 1 17763 592



                    PS C:Usersgaius> Write-Output $pwd

                    Path
                    ----
                    C:Usersgaius


                    That appears to work as expected, what versions of things are you using?



                    Compare to Linux:



                    gaius@klossy:~$ pwsh
                    PowerShell 6.2.2
                    Copyright (c) Microsoft Corporation. All rights reserved.

                    https://aka.ms/pscore6-docs
                    Type 'help' to get help.

                    PS /home/gaius> echo $pwd

                    Path
                    ----
                    /home/gaius

                    PS /home/gaius>


                    (echo is just an alias for Write-Output)



                    If you must have exact commonality between Windows and Linux there are a few solutions, Git comes with Bash for Windows, there's WSL, etc.






                    share|improve this answer















                    PS C:Usersgaius> Write-Output $PSVersionTable.PSVersion

                    Major Minor Build Revision
                    ----- ----- ----- --------
                    5 1 17763 592



                    PS C:Usersgaius> Write-Output $pwd

                    Path
                    ----
                    C:Usersgaius


                    That appears to work as expected, what versions of things are you using?



                    Compare to Linux:



                    gaius@klossy:~$ pwsh
                    PowerShell 6.2.2
                    Copyright (c) Microsoft Corporation. All rights reserved.

                    https://aka.ms/pscore6-docs
                    Type 'help' to get help.

                    PS /home/gaius> echo $pwd

                    Path
                    ----
                    /home/gaius

                    PS /home/gaius>


                    (echo is just an alias for Write-Output)



                    If you must have exact commonality between Windows and Linux there are a few solutions, Git comes with Bash for Windows, there's WSL, etc.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 7 hours ago

























                    answered 8 hours ago









                    GaiusGaius

                    7933 silver badges13 bronze badges




                    7933 silver badges13 bronze badges











                    • 1





                      This answer makes me look like a bit of an idiot :) -- and certainly show the gaps in my PowerShell knowledge. The developer claimed that ${PWD} wasn't working for them Unfortunately, I have no way of verifying this, not having access to a Windows machine. But certainly it looks like it should work (I'm using Powershell 6.2.2 on Linux)

                      – Bruce Becker
                      8 hours ago






                    • 1





                      @BruceBecker added the Linux to my answer

                      – Gaius
                      7 hours ago











                    • Actually now that I think about it some more, just recommend your Windows devs use Git Bash if they absolutely must do things the same way as Linux

                      – Gaius
                      7 hours ago














                    • 1





                      This answer makes me look like a bit of an idiot :) -- and certainly show the gaps in my PowerShell knowledge. The developer claimed that ${PWD} wasn't working for them Unfortunately, I have no way of verifying this, not having access to a Windows machine. But certainly it looks like it should work (I'm using Powershell 6.2.2 on Linux)

                      – Bruce Becker
                      8 hours ago






                    • 1





                      @BruceBecker added the Linux to my answer

                      – Gaius
                      7 hours ago











                    • Actually now that I think about it some more, just recommend your Windows devs use Git Bash if they absolutely must do things the same way as Linux

                      – Gaius
                      7 hours ago








                    1




                    1





                    This answer makes me look like a bit of an idiot :) -- and certainly show the gaps in my PowerShell knowledge. The developer claimed that ${PWD} wasn't working for them Unfortunately, I have no way of verifying this, not having access to a Windows machine. But certainly it looks like it should work (I'm using Powershell 6.2.2 on Linux)

                    – Bruce Becker
                    8 hours ago





                    This answer makes me look like a bit of an idiot :) -- and certainly show the gaps in my PowerShell knowledge. The developer claimed that ${PWD} wasn't working for them Unfortunately, I have no way of verifying this, not having access to a Windows machine. But certainly it looks like it should work (I'm using Powershell 6.2.2 on Linux)

                    – Bruce Becker
                    8 hours ago




                    1




                    1





                    @BruceBecker added the Linux to my answer

                    – Gaius
                    7 hours ago





                    @BruceBecker added the Linux to my answer

                    – Gaius
                    7 hours ago













                    Actually now that I think about it some more, just recommend your Windows devs use Git Bash if they absolutely must do things the same way as Linux

                    – Gaius
                    7 hours ago





                    Actually now that I think about it some more, just recommend your Windows devs use Git Bash if they absolutely must do things the same way as Linux

                    – Gaius
                    7 hours ago


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to DevOps Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdevops.stackexchange.com%2fquestions%2f9002%2fdocker-compose-volume-syntax-valid-for-windows-and-linux%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                    Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                    Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...