Web Server Load Balancing with NGINX Plus

Photon OS is a new lightweight Linux distribution from VMware, designed specifically to run containers.

Photon OS supports multiple container specifications, including Docker, rkt, and Pivotal Garden. One of the goals of Photon OS is to provide high performance when running on VMware vSphere. It comes with tdnf, a new yum‑compatible package manager for efficient lifecycle management. Photon OS also supports rpm-OSTree, which lets you perform versioned atomic upgrades of a filesystem tree across all Photon OS instances and supports an rpm‑based package manager for controlling the state of packages in the tree.

Photon OS is in a technical preview stage. It is released as open source software with source code and documentation available in a Github repository.

This post shows how simple it is to run NGINX Open Source and NGINX Plus in a Docker container on Photon OS. After explaining how to install Photon OS, we provide separate instructions for NGINX and NGINX Plus.

We assume that you are familiar with Docker. To get started with Docker, see the Docker documentation.

For a good introduction and instructions on how to run NGINX and NGINX Plus in Docker on any type of Docker host, see the Deploying NGINX and NGINX Plus with Docker blog post.

Installing Photon OS

You can start using Photon OS either by importing an OVA file into your virtualization software or by installing Photon OS from an ISO image. VMWare also provides experimental native images for Amazon Web Services, Google Cloud Environment, and Microsoft Azure. For detailed installation instructions, visit the Photon OS wiki.

Note: By default the Docker daemon is not started at boot time. To start the daemon, run this command:

# systemctl start docker

Running NGINX with Photon OS

Once our Photon OS instance up and running, we can start NGINX in a Docker container. (For NGINX Plus, see the next section.)

Run this command:

# docker run --name mynginx -p 8080:80 -d nginx

We map port 80 inside the container to port 8080 on our Photon OS host. After the NGINX image is pulled from Docker Hub, the NGINX container starts.

Now let’s check that NGINX is indeed running by running a curl command and verifying that we see the text of the default NGINX welcome page:

# curl localhost:8080
<!DOCTYPE html>
<title>Welcome to nginx!</title>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href=""></a>.<br/>
Commercial support is available at
<a href=""></a>.</p>
<p><em>Thank you for using nginx.</em></p>

Running NGINX Plus with Photon OS

Compared to NGINX, running NGINX Plus in a Docker container requires an additional step: we need to build an NGINX Plus container image, which is not available from Docker Hub.

Here’s a Dockerfile for building the image, using Ubuntu 14.04 as the base image. You need to put the nginx-repo.crt and nginx-repo.key files from your NGINX Plus subscription or trial in the same folder as the Dockerfile.

FROM ubuntu:14.04
MAINTAINER NGINX Docker Maintainers ""
# Set the debconf frontend to Noninteractive
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN apt-get update && apt-get install -y -q wget apt-transport-https ca-certificates
# Download certificate and key from the customer portal (
# and copy to the build context
ADD nginx-repo.crt /etc/ssl/nginx/
ADD nginx-repo.key /etc/ssl/nginx/
# Get other files required for installation
RUN wget -q -O - | apt-key add -
RUN wget -q -O /etc/apt/apt.conf.d/90nginx
RUN printf "deb `lsb_release -cs` nginx-plusn" > /etc/apt/sources.list.d/nginx-plus.list
# Install NGINX Plus
RUN apt-get update && apt-get install -y nginx-plus
# forward request logs to Docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log
RUN ln -sf /dev/stderr /var/log/nginx/error.log
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]

To build the image we run:

# docker build -t nginxplus .

Run this command to verify the image built successfully (it appears on the first line of the sample output):

# docker images
REPOSITORY       TAG              IMAGE ID         CREATED          VIRTUAL SIZE
nginxplus        latest           f0dfff373cf3     37 seconds ago   229 MB
nginx            latest           5c82215b03d1     6 days ago       132.8 MB
ubuntu           14.04            a005e6b7dd01     8 days ago       188.3 MB

To start a container using the image, we run:

# docker run --name mynginxlplus -p 80:80 -d nginxplus

Here we map port 80 inside the container to port 80 on the Photon OS host.

We can check if NGINX Plus is serving pages by running the curl localhost command and verifying that it outputs the default NGINX welcome page, as shown above for NGINX.

For more detailed instructions on how to run NGINX and NGINX Plus in a Docker container, including how to build the NGINX Plus Docker image, manage content, and set up NGINX configuration files and logging, see the Deploying NGINX and NGINX Plus with Docker blog post.


Photon OS is a lightweight Linux container host that is designed for high performance on VMware vSphere. NGINX and NGINX Plus can be easily deployed in a Docker container to deliver your apps in a Photon OS environment.

Want to get started with NGINX Plus? Sign up for a free 30‑day trial today.

Hero image
《NGINX 完全指南》2024 年最新完整版



Michael Pleshakov



F5, Inc. 是备受欢迎的开源软件 NGINX 背后的商业公司。我们为现代应用的开发和交付提供一整套技术。我们的联合解决方案弥合了 NetOps 和 DevOps 之间的横沟,提供从代码到用户的多云应用服务。访问 了解更多相关信息。