-
For more details, see Install NGINX in
Docker:
For: * Prerequisites * Running NGINX Plus in a Docker Container * Managing
Content and Configuration Files * Maintaining Content and Configuration
Files in the Container * Managing Logging * Controlling NGINX
-
See K06248495: Quick deployment: NGINX within a Docker container
: For: * Download and deploy the
NGINX Docker image file * Stop, restart, and remove an existing container *
Update web pages and view NGINX log files within a running container
NGINX Unprivileged Docker
NGINX Plus with Controller Agent
- See
docker-nginx-controller
for example Dockerfiles deploying NGINX Plus as Container, with and without
NGINX App Protect and Controller Agent
Networking using the host network
- See: https://docs.docker.com/network/network-tutorial-host/
Using the −−network host
the host network driver automatically uses the Host
network Interface (e.g. “eth0
”) when running on linux/unix systems.
Avoid NGINX “Too many open files” error and Increasing Docker ulimits
A common bottleneck in the default Linux operating system configuration is a
lack of file descriptors.
Tuning the Linux OS for improve throughput capabilies in and out of the Docker
Host machine still apply when Hosting Docker Containers but understand that
Docker is able to set an ulimit different from the host.
we can also ensure yout docker container has adequate ulimit settings through
the command line and the API. For instance, docker run takes `— ulimit
=:` .
### Global change (affects all containers)
The default limit for open files is 1024 in Docker containers and on many cloud
container platforms. In Unix systems, you can increase the limit by following
commands lower limits to what is set on the Host.
1. You can increase those limits set by docker by executing the following
command:
```bash systemctl show docker ```
1. Search for NOFILE and If the output is “`1024`”, edit the file:
`/etc/sysconfig/docker`
1. Replace the line (may look like or similar "low" numbers):
```bash OPTIONS=" — default-ulimit nofile=1024:4096" ```
with:
```bash OPTIONS="--default-ulimit nofile=1024000:1024000" ```
1. Restart the Docker daemon.
```bash sudo systemctl restart docker ```
1. Verify that the limit has been updated:
```bash # Docker docker exec -it - -- /bin/sh -c ‘ulimit
-a’
# Kubernetes kubectl exec -it -n sisense -- /bin/sh -c ‘ulimit
-a’ ```
## Change specific container limit
Any `ulimit` values that you specify for a container override the default values
that you set for the daemon.
In this case please run the container with the following option:
```bash
# docker run -it --ulimit nofile=122880:122880 centos
```
`122880` is the hard and soft open files limit for the container “centos”.
## Tuning NGINX for Performance
Typical NGINX performance tuning still applies to NGINX deployed in Containers
See
* [Tuning NGINX for Performance](https://www.nginx.com/blog/tuning-nginx/)
* [Performance Tuning – Tips &
Tricks](https://www.nginx.com/blog/performance-tuning-tips-tricks/)
## Docker Restart Policy for Host reboot
Ensure your Docker containers automatically start upon a Docker Host reboot
You can apply whatever Restart Policy you prefer after the --restart option, so:
```bash
# -restart no policy, is the default.
# Other options include
--restart on-failure
--restart always
--restart unless-stopped
```
## Restart NGINX
Restart the container if the new config data is mounted and read from a volume.
```bash
docker exec -it nginx nginx -s reload
```