NGINX is a web server that can be also used as a reverse proxy, load balancer, and HTTP cache. Recommended for high-demanding sites due to its ability to provide faster content.
This image based on Alpine Linux with s6-overlay.
Multi-platform available trough docker manifest. More information is available from docker here.
Simply pulling using latest
tag should retrieve the correct image for your arch.
The architectures supported by this image:
Architecture | Available |
---|---|
x86-64 | ✅ |
arm64 | ✅ |
This Nginx-FPM image exposes a volume at /config
add your web files to /config/www
for hosting. Content mounted here is served by the default catch-all server block.
Modify the nginx, and site config files under /config
folder as needed .
Here are some example to help you get started creating a container, easiest way to setup is using docker-compose or use docker cli.
- docker-compose (recommended)
version: "3.9"
services:
nginx:
image: imoize/nginx-fpm:latest
container_name: nginx_fpm
environment:
- PUID=1001
- PGID=1001
- TZ=Asia/Jakarta
volumes:
- /path/to/app/data:/config
ports:
- 8080:80
- 9443:443
restart: always
- docker cli
docker run -d \
--name=nginx_fpm \
-e PUID=1001 \
-e PGID=1001 \
-e TZ=Asia/Jakarta \
-p 8080:80 \
-p 9443:443 \
-v /path/to/app/data:/config \
--restart always \
imoize/nginx-fpm:latest
Access your web server in the browser by navigating to http://ip-address:8080 or https://ip-address:9443
Name | Description | Default Value |
---|---|---|
PUID | User UID | |
PGID | Group GID | |
TZ | Specify a timezone see this list. | UTC |
S6_VERBOSITY | Controls the verbosity of s6-rc. See this. | 1 |
When you start the Nginx image, you can adjust the configuration of the instance by passing one or more environment variables either on the docker-compose
file or on the docker run
command line. Please note that some variables are only considered when the container is started for the first time. If you want to add a new environment variable:
- for
docker-compose
add the variable name and value:
nginx:
...
environment:
- PUID=1001
...
- for manual execution add a
-e
option with each variable and value:
docker run -d \
-e PUID=1001 \
imoize/nginx-fpm:latest
You can change/override php.ini
and www.conf
, by edit or add config to php-local.ini
and www2.conf
in /config/php
folder.
If you remove the container all your data will be lost, and the next time you run the image the data and config will be reinitialized. To avoid this loss of data, you should mount a volume that will persist even after the container is removed.
For persistence you should map directory inside container in /config
path to host directory as data volumes. Application state will persist as long as directory on the host are not removed.
e.g: /path/to/app/data:/config
/config
folder contains www content and all relevant configuration files.
When using volumes (-v
flags) permissions issues can arise between the host OS and the container, to avoid this issue you should specify the user PUID
and group PGID
.
Ensure any volume directories on the host are owned by the same user you specify and any permissions issues will be solved.
For example: PUID=1001
and PGID=1001
, to find yours user id
and gid
type id <your_username>
in terminal.
$ id your_username
uid=1001(user) gid=1001(group) groups=1001(group)
- Shell access whilst the container is running:
docker exec -it nginx_fpm /bin/bash
- To monitor the logs of the container in realtime:
docker logs -f nginx_fpm
- Container version number:
docker inspect -f '{{ index .Config.Labels "build_version" }}' nginx_fpm
- Image version number:
docker inspect -f '{{ index .Config.Labels "build_version" }}' imoize/nginx-fpm:latest
NOTE: nginx_fpm
is name of the container.
We recommend that you follow these steps to upgrade your container.
docker pull imoize/nginx-fpm:latest
or if you're using Docker Compose, update the value of the image property to
imoize/nginx-fpm:latest
.
Stop the currently running container using this command.
docker stop nginx_fpm
or using Docker Compose:
docker-compose stop nginx_fpm
Remove the currently running container using this command.
docker rm -v nginx_fpm
or using Docker Compose:
docker-compose rm -v nginx_fpm
Re-create your container from the new image.
docker run --name nginx_fpm imoize/nginx-fpm:latest
or using Docker Compose:
docker-compose up -d nginx_fpm
You can also remove the old dangling images.
docker image prune
NOTE: if volume mapped correctly to a host folder, your /config
folder and settings will be preserved.
We'd love for you to contribute to this container. You can submitting a pull request with your contribution.
If you encountered a problem running this container, you can create an issue.