Running nginx with podman on MicroOS: doesn't create config and htdocs files?

Hi all,

I’m new with MicroOS (and also rather new with containers (so be patient with me please LOL), and I’m trying to set up an nginx server.

For noobs like me I’ve documented my struggles, hoping it will help someone, as it is really hard to find examples on how to do this!

The questions are at the bottom!

I’m following this page: Portal:Container/Image/nginx - openSUSE Wiki . For this to work I had to install containers-systemd, which is not part of the microos image.

sudo transactional-update pkg in containers-systemd

And rebooted afterwards.

Then, I created the /srv/nginx/etc and /svr/nginx/htdocs as per the docs.
(with sudo, as the /srv directory isn’t writable for my user, and had to chmod these dirs…

Then I ran this:

sudo podman run -d --rm -v /srv/nginx/etc:/etc/nginx:Z -v /srv/nginx/htdocs:/srv/www/htdocs:Z --name nginx -p 80:80/tcp -p 443:443/tcp registry.opensuse.org/opensuse/nginx

The :Z because as I understand SElinux is default on MicroOS, and the docs told me to use :Z in that case.
And as sudo, otherwise it wasn’t able to bind the ports.

Then running:

sudo systemctl start container-nginx

looked like it was okay ,but the status told me it failed (start request repeated to quickly)

So I ran the podman command without the -d and discovered that an nginx config was missing. So I put a default nginx.conf on my host ( /srv/nginx/etc/nginx.conf) and ran the podman command again.

Now it worked! If I went to localhost:80 on my browser it showed me an nginx page (a 404, but at least it found nginx).
Created an index.html and everything was fine.

Now… the question(s):

Question 1:
1st of all: did I go about it the correct way? Any oversights I made, any tips for doing it better, or another way? With distrobox (as that is said to be the go-to way after flatpaks)?

Question 2:
According to the docs :

This container image requires a local data directory, by default /srv/nginx. During the first start, if no configuration is provided, the container will create a default configuration:
/srv/nginx/etc contains the configuration normally can be found in /etc/nginx
/srv/nginx/htdocs contains the files which normally can be found below /srv/www/htdocs

Which it clearly didn’t do. Is this no longer the case or did I miss something?

Question 3:
As MicroOS server would rely on services running in containers, why isn’t containers-systemd in the image by default?

Any insights would be very appreciated!

Mars

Anybody that can point me in the right direction? I’m at a loss here.

What is the best way to run an nginx server on MicroOS?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.