The advantage of the last tutorial is that is it uses docker-compose (which I replaced with podman-compose) and this command gives me a more detailed error message:
[Sat Jan 29 22:05:52.524991 2022] [core:error] [pid 12] (13)Permission denied: [client 10.89.0.2:48566] AH00035: access to /index.html denied (filesystem path '/var/www/html/index.html') because search permissions are missing on a component of the path
So there is still a permission problem I can’t get rid of. Does somebody have an idea how to solve this? Has there anybody who successfully run Apache in a container on Fedora Silverblue? Tell me how ! I really would like to setup a PHP development environment on my machine.
Since it’s Sunday, let’s try the big-hammer approach to narrowing down the problem — if you put selinux in non-enforcing mode, does it work? That will help us know where to go next.
ELinux is preventing apache2 from associate access on the filesystem 2.
***** Plugin catchall (100. confidence) suggests **************************
If you believe that apache2 should be allowed associate access on the 2 filesystem by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'apache2' --raw | audit2allow -M my-apache2
# semodule -X 300 -i my-apache2.pp
I ran the commands ausearch -c 'apache2' --raw | audit2allow -M my-apache2 and semodule -i my-apache2.pp, and ran the container again but the error message keeps returning.
Hi Scott,
I had done one using Postgresql for nextcloud on F33 Silverblue, which was basically this script podman run --detach --env PGDATABASE=nextcloud --env PGUSER=<username> --env PGPASSWORD=<pgdbpasswd> --env PGROOTPASSWORD=<pgrootpwd> --volume nextcloud-db:/var/home/<host-user-name>/.local/share/containers/storage/\ volumes/nextcloud-db/_data --network nextcloud-net --restart on-failure --name nextcloud-db registry.fedoraproject.org/f33/postgresql
Plus, there is a really good reference about Podman, selinux and rootless containers https://www.redhat.com/sysadmin/user-namespaces-selinux-rootless-containers. I feel this is a user mapping or volume mapping for the db that is at the heart of the issue for you. I’ll look at what else I have … https://access.redhat.com/articles/1328953 this is about doing it with docker and redhat.
Thanks for the articles! I will read them with the hope that I will find something that could solve my problem. I’m not using a database but that’s something I could add after I solved the 403 error.
Yeah it will start a container as long a the directory Websites exists off of wherever the command is issued from. But I don’t have permission to access the website while I can attach to the container and if I add a /bin/bash command to the end, can get a CLI like so
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1932a9bb4039 docker.io/library/php:7.2-apache /bin/bash 17 seconds ago Up 17 seconds ago 0.0.0.0:8080->80/tcp my-apache-php-app
attached to the running container like this …
podman attach 1932a9bb4039 01/31/22-14:59:15
root@1932a9bb4039:/var/www/html# ls
So now back to the original command you asked us to try, it starts a container successfully if I have a Websites directory off of wherever I am (pwd is used in your command), and I cannot access the site since I don’t have permissions is what the browser states (Firefox and LibreWolf). This is very likely because I do not have anything in /var/www/html/. This would need to be in existence in the container. See the error output of the attached to running container on my system …
[Mon Jan 31 20:06:59.365062 2022] [autoindex:error] [pid 12] [client 10.0.2.100:52080] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
10.0.2.100 - - [31/Jan/2022:20:06:59 +0000] "GET / HTTP/1.1" 403 493 "-" "Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
10.0.2.100 - - [31/Jan/2022:20:06:59 +0000] "GET /favicon.ico HTTP/1.1" 404 489 "http://127.0.0.1:8080/" "Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
If you’re trying to map ~/Websites/ on the host to /var/www/html/ on the container it would need to be something like podman run --rm --detach -p 8080:80 --name my-apache-php-app --volume /var/home/<host-user-name>/Websites volumes/my-apache-php-app/var/www/html/ I think.
Yes, the last command is exactly what I try to do: mount the directory Websites in my home directory with the directory /var/www/html in the container.
I made some progress: I copied the file index.php to container and now I get to see the generated web page!
Copying the file
podman cp index.php 5e7cff4097ea:/var/www/html
Result on localhost:8080
Hello from inside the container!
Conclusion: Apache and PHP are running fine in the container!
Only the mounting of the directory Websites with /var/www/html goes wrong.
Yes, it behaves as expected: I can now run all the PHP files inside the directory Websites!
The only thing I have to figure out is how to enable directory listing. Normally you would do this with Options Indexes but sadly that didn’t work (I copied a modified version of the file 000-default.conf to the container).