Logo

Armand.nz

Home / About / Linkedin / Github

Deploying NGINX and NGINX Plus on Docker

#docker #nginx |

NGINX Unprivileged Docker

NGINX Plus with Controller Agent

Networking using the host network

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 ```
comments powered byDisqus

Copyright © Armand