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 the open source NGINX software 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 guide for your base operating system:
- Get Started with Docker for Linux
- Get Started with Docker for Mac OS X
- Get Started with Docker for Windows
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
<title>Welcome to nginx!</title>
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
Commercial support is available at
<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.
MAINTAINER NGINX Docker Maintainers "email@example.com"
# 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 (https://cs.nginx.com)
# 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 - http://nginx.org/keys/nginx_signing.key | apt-key add -
RUN wget -q -O /etc/apt/apt.conf.d/90nginx https://cs.nginx.com/static/files/90nginx
RUN printf "deb https://plus-pkgs.nginx.com/ubuntu `lsb_release -cs` nginx-plus\n" > /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
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.