在遵循docker文檔中的示例時無法讀取數據。可能,我的碼頭配置有問題嗎?無法讀取來自綁定分區的數據
按照此創建一個容器:https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-file-as-a-data-volume
docker run --rm -it -v ~/.bash_history:/root/.bash_history ubuntu /bin/bash
當我試着從容器中的歷史,我得到了「權限被拒絕錯誤」:
[email protected]:/# history
1 ls -la ~/
2 history
[email protected]:/# cat ~/.bash_history
cat: /root/.bash_history: Permission denied
是有關.bash_history文件的所有權,這裏有什麼不對嗎?
[email protected]:/# ls -la ~/
total 60
drwx------ 2 root root 4096 Mar 8 21:14 .
drwxr-xr-x 35 root root 4096 Mar 8 21:14 ..
-rw------- 1 nobody nogroup 42996 Mar 8 21:06 .bash_history
-rw-r--r-- 1 root root 3106 Oct 22 2015 .bashrc
-rw-r--r-- 1 root root 148 Aug 17 2015 .profile
4.4和4.10內核都給出了相同的結果。
我在Linux Mint 18.1上。下面是一些系統信息:
$ uname -a
Linux a 4.4.0-65-generiC#86-Ubuntu SMP Thu Feb 23 17:49:58 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ docker --version
Docker version 17.03.0-ce, build 3a232c8
$ docker info
Containers: 39
Running: 1
Paused: 0
Stopped: 38
Images: 269
Server Version: 17.03.0-ce
Storage Driver: aufs
Root Dir: /var/lib/docker/296608.296608/aufs
Backing Filesystem: extfs
Dirs: 395
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 977c511eda0925a723debdc94d09459af49d082a
runc version: a01dafd48bc1c7cc12bdb01206f9fea7dd6feb70
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
userns
Kernel Version: 4.4.0-65-generic
Operating System: Linux Mint 18.1
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.55 GiB
Name: a-dell
ID: IEJP:6N34:GFBS:VIOM:HDBW:NVOF:BH3E:HZFO:3SOE:AACN:VZCV:FSWZ
Docker Root Dir: /var/lib/docker/296608.296608
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
UPDATE
我看到的問題是文件訪問權限/屬性。當我更改.bash_history的屬性以允許所有人閱讀時,docker容器都可以訪問它。有沒有辦法與我運行的容器共享我的文件訪問權限?
我看到問題出在文件訪問權限/屬性上。當我改變我的.bash_history的屬性以允許所有人閱讀時,docker cann可以訪問它。你知道一種方法來與我運行的容器分享我的訪問權嗎? – anddr