Serving static content with Nginx via Docker

I was playing around with the nginx docker container recently and wanted to serve the content from the local directory that I was in (pwd). This is how I ended up doing it:

docker run --name nginx -d --rm -p 8080:80 -v $(pwd):/usr/share/nginx/html nginx:1.7 

That will launch an nginx docker container and serve whatever is in the local directory, as static content, and map the docker container port 80 to the localhost port 8080.

Note that the

--rm

flag will remove the container when stopped.

Leave a Reply

Your email address will not be published. Required fields are marked *