2018年7月24日 星期二

[Docker] Trouble shooting - Cannot mount the data volume


 Docker   Data volumes  

While mounting a host’s data volume to a container, I could not find the folder/files inside the folders.

$ ls /www/html
index.html

$ docker run -d -P -v "$(pwd)/www":/app:ro apache2-webserver /bin/bash
root@xxxx:/app# ls
root@xxxx:/app#


Here is my way to solve it,

1.  Change host’s absolute path to relative path

2.  Update the settings of VM to allow sharing certain drives or directories to Docker.

For example, in VM VirtualBox manager, find the Sharing folders and add the path.





After did so, it works like a charm.

$ ls /www/html
index.html

$ docker run -d -P -v "/www":/app:ro apache2-webserver /bin/bash
root@xxxx:/app# ls
html
root@xxxx:/app# ls html
index.html



Reference






沒有留言:

張貼留言