Mount current directory as a volume in Docker on Windows 10

后端 未结 10 1033
滥情空心
滥情空心 2020-11-28 01:22

Description

I am using Docker version 1.12.5 on Windows 10 via Hyper-V and want to use container executables as commands in the current path. I buil

10条回答
  •  感动是毒
    2020-11-28 01:29

    In Windows Command Line (cmd), you can mount the current directory like so:

    docker run --rm -it -v %cd%:/usr/src/project gcc:4.9
    

    In PowerShell, you use ${PWD}, which gives you the current directory:

    docker run --rm -it -v ${PWD}:/usr/src/project gcc:4.9
    

    On Linux:

    docker run --rm -it -v $(pwd):/usr/src/project gcc:4.9
    

    Cross Platform

    The following options will work on both PowerShell and on Linux (at least Ubuntu):

    docker run --rm -it -v ${PWD}:/usr/src/project gcc:4.9
    docker run --rm -it -v $(pwd):/usr/src/project gcc:4.9
    

提交回复
热议问题