Run an Nginx Image as Non-Root Within a Multi-Step Docker Build Process

InstructorJoel Lord

Share this video with your friends

Send Tweet

Running our server as a Non-Root user is very important for testing things such as quality assurance. Many things can get missed when using a privileged account such as your root user account. Here we need to set up and change the Nginx configuration to run as a Non-Root user.

This container uses two steps. The first step uses a container to build the production version of your VueJs application. This container won’t be deployed on a server, its purpose is to create the necessary files for the second step. It's fine to leave this container running as root.

In the next step of the build, the Nginx server is the one that will need to run as a non-root user because it is actually run on servers you want to deploy to. To do so, you will first need to change the Nginx configuration to run the build using the Nginx user with files modified for that user to access them.