Deploy quick ghost blog with Docker and SSL from letsencrypt

When setting up this blog I wanted to host it myself and all within Docker from one script, So I could run it up quick on a new box or move it into the cloud later.

I found some good guides online but didn’t find one that had everything I wanted in one place, I found that they would have a good setup for ghost but didn’t have the reverse proxy or letsencrypt in dockers. I really wanted everything to be in one place to be able to move it quick or run it up again fast.

I ended up using three dockers, a nginx-proxy docker to reverse proxy connects to the docker host from the internet to the blog. Then a letsencrypt docker to get a SSL cert for the site and finely the blog it’s self running on ghost.

First we setup the nginx reverse using the nginx-proxy docker, you will need to have port 80 and 443 open from the internet to your docker host and point your domain to that host for this to work. I’m using cloudflare for my domains DNS but anything should work. more can be found on this here cloudflare

Open nano on your docker host to start setting up a script

 sudo nano

Copy and past the three docker run commands into the script

 docker run -d -p 80:80 -p 443:443 \
--name nginx-proxy \
-v /home/user/docker/certs:/etc/nginx/certs:ro \
-v /etc/nginx/vhost.d \
-v /usr/share/nginx/html \
-v /var/run/docker.sock:/tmp/docker.sock:ro \
--label com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true \

With this next part we use the letsencrypt docker to get a SSL cert for our blog

docker run -d \
--name nginx-letsencrypt \
--volumes-from nginx-proxy \
-v /home/user/docker/certs:/etc/nginx/certs:rw \
-v /var/run/docker.sock:/var/run/docker.sock:ro \

Then last but not least is the ghost blog it’s self.

docker run --name blog --expose 2368 -d \
-e NODE_ENV=production \
-e \
-e \
-e \
-e "" \
-e "" \
-v /home/user/docker/blog/:/var/lib/ghost \

Save the script by pressing Ctral + X then Y to save

Make the script executable by running

sudo chmod +x

Now everything need for a quick blog to be setup on docker host

Start the blog by running the new script

sudo sh

You should now see the docker host download and start the reverse proxy, get an SSL cert from letsencrypt and then start the blog.

Give it a tad bit of time and then go to the blogs admin page to start setting it up, it should be

If you later need to move your site to a new host / into the cloud all you need to do is copy your docker data the /docker folder in your user drive and the script to a new host, update DNS on your domain and start it back up.