Simple way to serve a website using nginx and docker

#docker

Once in a while, I need something to serve files, last time I was going to share a VBox image. In my experience, it is better to share large files using HTTP.

The simplier way is this:

$ docker run --rm -v $(pwd):/usr/share/nginx/html:ro -p 80:80 nginx

Another way is to start it in background:

$ docker run -d --name=static --rm -v $(pwd):/usr/share/nginx/html:ro -p 80:80 nginx

While using the -d (or --detach=true) parameter, I always recommend giving a name to the container (using the parameter --name=), because it is possible to stop the container using that name:

$ docker stop static

Remember: This is for static HTML page.

References