PodmanでローカルフォルダーをContainerへ共有する
いろいろな事情で、dockerの代わりにPodmanを使用している。runコマンドを実行する際に、ローカルフォルダーをContainerへ共有する
-v ローカルフォルダー:Container内のフォルダー
のオプションをつけても、Container内からフォルダーしか見えなくて、フォルダー内のファイルやサブフォルダーが見えない。
Google先生に聞いたら、以下の回答をもらった。
Common Causes and Solutions:
- Problem: SELinux, if enabled on the host, can restrict container access to mounted volumes.
- Solution: Append
:zor:Zto the volume mount option in yourpodman runcommand.
:zrelabels the volume for shared use among multiple containers.:Zrelabels the volume for private use by a single container.- Example:
podman run -v /host/path:/container/path:z my_image
つまり、オプションの最後に「:z」か「:Z」をつければよい。
試しに
-v ローカルフォルダー:Container内のフォルダー:Z
のオプションで再度runコマンドを実行したら、フォルダー内のファイルやサブフォルダーが見えるようになった。