Would you like to learn how to install Nginx using Docker on Ubuntu Linux? In this tutorial, we are going to show you all the steps required to perform the Nginx installation using Docker on a computer running Ubuntu Linux in 5 minutes or less.

• Ubuntu 20.04
• Ubuntu 18.04
• Ubuntu 19.04
• Nginx 1.19.2

Equipment list

The following section presents the list of equipment used to create this tutorial.

As an Amazon Associate, I earn from qualifying purchases.

Tutorial Nginx - Docker Installation on Ubuntu Linux

Install the Docker service.

Copy to Clipboard

Download the Nginx docker image from the online repository.

Copy to Clipboard

List the Docker images installed on your system.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Start a new Nginx container using this Docker image.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

In our example, the Docker image was used to start a new container.

The new container is using the local port 80.

The container ID is 177e8effa98fdf8fcc87d377203106d80502cfce10ef7cc619af859577841f56.

Congratulations! You have finished the Nginx Docker installation on Ubuntu Linux.

Docker Nginx - Persistent data

Create a docker volume for persistent data.

Copy to Clipboard

Verify the persistent data directory.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Optionally, create a symbolic link to an easier access location.

Copy to Clipboard

Start an Nginx container with persistent data storage.

Copy to Clipboard

Verify the content of the persistent data directory.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Congratulations! You successfully configured the use of Docker persistent data storage.

Tutorial Nginx - Testing the Docker installation

Open your browser and enter the IP address of your web server.

In our example, the following URL was entered in the Browser:

• http://192.168.100.10

The Nginx server will display the default website.

nginx welcome

Congratulations! Your Nginx Docker installation was tested successfully.

Tutorial Nginx - Docker container management

Verify the status of all Docker conteiners using the following command:

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Verify the status of the Nginx container using the ID or its name.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

To stop the Nginx container service, use the following command:

Copy to Clipboard

To start the Nginx container service, use the following command:

Copy to Clipboard

To restart the Nginx container service, use the following command:

Copy to Clipboard

In case of error, use the following command to verify the Nginx container logs.

Copy to Clipboard

In our examples, we demonstrated how to manage the Nginx container using its ID or the name previously defined.