Setting up NGINX inside Docker
Having become familiar with Docker Compose, we’re set to advance our container usage. In this section, we’ll improve our NGINX container by adding personalized configurations and website content.
Let’s begin by revisiting the docker-compose.yml
file we created earlier. This file already specifies the NGINX service and maps the container’s port 80 to port 80 on the host machine, making the web server accessible from the host.
Next, we want our NGINX container to serve our website using the actual configuration files and content from our host machine. To achieve this, we’ll use Docker volumes. Volumes are the preferred mechanism for persisting data generated and used by Docker containers. Here’s how you can modify the docker-compose.yml
file to mount a volume:
version: '3' services:   nginx:     image: nginx:latest     ports:    ...