Published on 2020-04-16

Running a private blog using Eleventy and Docker

Eleventy, Docker

Create a Dockerfile with one single line

FROM nginx:alpine

Then build the image using the command

$ docker build -t my-private-blog .

Now run with the following command

$ docker run -d -p 8000:80 -v c:/Workspace/Non-Obex/my-private-blog/_site:/usr/share/nginx/html my-private-blog

Let's explain each of the option:

If we need to run sh shell, run the command

$ docker ps

then look for the name of the container in the output. It's usually 2 random words concat by an underscore. For example it might be something like hungry_shamir.

Then run

$ docker exec -it hungry_shamir /bin/sh

The nice thing is as we write more posts, all we have to do is running the command eleventy. The refresh the browser. The new posts will be reflected automatically.