次のコマンドを使用してDockerコンテナーを実行し、host(/root/database
)からcontainer(/tmp/install/database
)にディレクトリをマップします。
# docker run -it --name oracle_install -v /root/database:/tmp/install/database bofm/oracle12c:preinstall bash
しかし、コンテナでは、自分はすべての特権を持っていますが、ls
コンテンツの一覧表示に使用できないことがわかりました。/tmp/install/database/
root
[root@77eb235aceac /]# cd /tmp/install/database/
[root@77eb235aceac database]# ls
ls: cannot open directory .: Permission denied
[root@77eb235aceac database]# id
uid=0(root) gid=0(root) groups=0(root)
[root@77eb235aceac database]# cd ..
[root@77eb235aceac install]# ls -alt
......
drwxr-xr-x. 7 root root 4096 Jul 7 2014 database
私/root/database
はホストをチェックインしましたが、すべて問題ありません:
[root@localhost ~]# ls -lt
......
drwxr-xr-x. 7 root root 4096 Jul 7 2014 database
Dockerコンテナが「アクセスが拒否されました」と表示するのはなぜですか?
更新:
根本的な原因はに関連していSELinux
ます。実は昨年も似たような問題に出会いました。
共有ディレクトリのコンテナ内で拒否された権限は、この共有ディレクトリがデバイスに保存されていることが原因である可能性があります。デフォルトでは、コンテナはどのデバイスにもアクセスできません。オプションを追加$docker run --privileged
すると、コンテナーはすべてのデバイスにアクセスしてカーネル呼び出しを実行できます。これは安全とは見なされていません。
デバイスを共有するより明確な方法は、オプションを使用することですdocker run --device=/dev/sdb
(共有するデバイスがある場合/dev/sdb
)。
manページから:
--device=[] Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm) --privileged=true|false Give extended privileges to this container. The default is false. By default, Docker containers are “unprivileged” (=false) and cannot, for example, run a Docker daemon inside the Docker container. This is because by default a container is not allowed to access any devices. A “privileged” container is given access to all devices. When the operator executes docker run --privileged, Docker will enable access to all devices on the host as well as set some configuration in AppArmor to allow the container nearly all the same access to the host as processes running outside of a container on the host.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加