简体   繁体   中英

Docker container not mounting volume properly

I have the following directory:

.
└── wordpress
    └── important-file.txt

1 directory, 1 files

My problem is that when I run the command below on my local WSL / Ubuntu :

$ docker run -it --rm -v "$(pwd)"/wordpress:/var/www/html php:7.3-fpm-alpine /bin/sh

I was expecting to find file: important-file.txt inside directory: /var/www/html , but the directory was empty.

I tried this on two different local computers and the result was the same. So, if you try it, probably you will get the same result.

In the other hand , if I run the same command on a Digital Ocean droplet the file is there.

Local WSL / Ubuntu system:

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

Digital Ocean droplet

# cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

The file sharing of my Docker Desktop looks like:

在此处输入图片说明

Any idea on why I don't get that file on my local WSL / Ubuntu system?

I found the solution here:

https://github.com/docker/for-win/issues/3385#issuecomment-533279510

Specifically what I did was:

  1. Give: docker-users full control over the directory I want to mount:

在此处输入图片说明

  1. On the Windows console, run the command:
> icacls wordpress /q /c /t /grant docker-users:F
  1. Restart the service: LxssManager :

在此处输入图片说明

  1. Close and ReOpen the WSL / Ubuntu .

在此处输入图片说明

  1. Try again:

在此处输入图片说明

That did the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM