Mount current directory as a volume in Docker on Windows 10

后端 未结 10 1032
滥情空心
滥情空心 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:42

    1. Open Settings on Docker Desktop (Docker for Windows).
    2. Select Shared Drives.
    3. Select the drive that you want to use inside your containers (e.g., C).
    4. Click Apply. You may be asked to provide user credentials.

    5. The command below should now work on PowerShell (command prompt does not support ${PWD}):

      docker run --rm -v ${PWD}:/data alpine ls /data

    IMPORTANT: if/when you change your Windows domain password, the mount will stop working silently, that is, -v will work but the container will not see your host folders and files. Solution: go back to Settings, uncheck the shared drives, Apply, check them again, Apply, and enter the new password when prompted.

提交回复
热议问题