7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Dockerでvolumesに指定したNFSのディレクトリがマウント出来ない時のTips

Posted at

問題

NFSでマウントしてるディレクトリをDockerのvolumesに指定してもコンテナ内に入るとマウントされていない。
また、エラー表示も特にない。

[root@dev ~]$ mount
192.0.2.1:/exports/share on /exports type nfs (rw,vers=4,addr=192.0.2.1,clientaddr=192.0.2.2)
[root@dev ~]$ ls /exports
aaa  bbb  ccc
[root@dev ~]$ docker run -it --name test -v /exports:/exports centos:latest bash
[root@00cb9276b6d2 /]# ls /exports
[root@00cb9276b6d2 /]# ls /exports/aaa
ls: cannot access /exports/aaa: No such file or directory

関連Issue, forum, stackoverflow

解決策

dockerのサービス起動前に、mountしてあればいい。
逆に言えば、dockerのサービス起動後にmountしたものは認識しない。1

# /etc/fstabに設定記載済みの想定
[root@dev ~]$ mount /exports
[root@dev ~]$ service docker restart
[root@dev ~]$ docker run -it --name test -v /exports:/exports centos:latest bash
[root@1942aa4640d1 /]# ls /exports
aaa  bbb  ccc
  1. NFSに限らず、cdromやusb-hddなどでも発生するかもしれない。

7
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?