Portal:Container/Image/nginx

Jump to: navigation, search

openSUSE Nginx Container Image

Description

This container image contains the latest nginx web server from openSUSE Tumbleweed.

Location

  • registry.opensuse.org/opensuse/nginx

Configuration

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

Note on SELinux

Users using SELinux (Default on MicroOS) need to specify :Z option to volume volume mount, which tells Podman to relabel the volume's content to match the label inside the container.

In the next example it would be

 -v /srv/nginx/etc:/etc/nginx:Z -v /srv/nginx/htdocs:/srv/www/htdocs:Z


This would be data from example after podman is done with relabeling

 lkocman@localhost:/srv/nginx/htdocs> ls -laZ /srv/nginx/htdocs/
 total 8
 drwxr-xr-x. 1 root root system_u:object_r:container_file_t:s0:c329,c865  36 Jul 26 13:36 .
 drwxr-xr-x. 1 root root unconfined_u:object_r:var_t:s0                   18 Jul 26 13:11 ..
 -rw-r--r--. 1 root root system_u:object_r:container_file_t:s0:c329,c865 497 Jul 13 15:04 50x.html
 -rw-r--r--. 1 root root system_u:object_r:container_file_t:s0:c329,c865 360 Jul 26 13:36 index.html

Run

 # mkdir -p /srv/nginx/etc /srv/nginx/htdocs

Make sure to specify :Z option for volumes format -v src:dest:options in case you're using SELinux.

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

It's possible to only override nginx.conf

 # podman run -d --rm -v /srv/nginx/etc/nginx.conf:/etc/nginx/nginx.conf:ro --name nginx -p 80:80/tcp -p 443:443/tcp registry.opensuse.org/opensuse/nginx

Reload Configuration

XXX

Systemd support

The package containers-systemd contains a service file and sysconfig file to configure and automatically start the nginx container with systemd.

 # systemctl start container-nginx