podman

mount directory to container won't work with podman


As I have fedora I tried to run the nginx example from their tutorial, i don't get nginx to show any content.

When i run the this container:

podman run --name mynginx1 -p 8080:80 -d nginx

I get the Welcome to nginx! page.

But when i try to run the example with a directory mounted:

podman run --name mynginx2 \
  --mount type=bind,source=/home/simon/Dokumente/podman/nginx/content,target=/usr/share/nginx/html \
  -p 9080:80 -d nginx

I also get the Welcome to nginx! page, but I have an index.html file in that source directory.

What is the problem with that container?


Solution

  • Yes , indeed it's a SElinux issue as @harik , but disabling selinux is not a secure option, rather apply the Z flag when mounting the volume, this deals with applying the appropriate labels as mentioned here and also here

    podman run --name mynginx2 \
      -v /home/simon/Dokumente/podman/nginx/content:/usr/share/nginx/html:Z \
      -p 9080:80 -d nginx