Nginx Container for React with Docker Compose

Tiempo de lectura: < 1 minuto

Today I’m going to share a container setup for React based on Nginx.

To do this, we are going to create this docker-compose.yml

Now we are going to create our Dockerfile

Finally, we will create the necessary folders:

The nginx.conf file must contain:

Remember that the React distribution folder generated with Vite is inside dist, you must place it in the root of this configuration.

So it looks like this:

Now we will use the command:

docker compose up -d

And we will be able to see the result on port 80: localhost:80.

Leave a Comment