/ tech

How Do I Setup A Free Website Using Docker?

cloudhero.io is developing a Docker container service in the cloud. While it's in development, they are offering a free Docker node within which you can run containers. This is perfect for creating a small website.

Beware, cloudhero.io does not guarantee your data will be safe.

In fact, they had a server problem which resulted in total loss of everything I had stored in my Docker containers. Regardless, this is a very handy service, just keep your data backed up.

The following steps show how to:

  • Connect your docker installation to the cloudhero.io cluster
  • Create a ghost container
  • Create a ghost-data container
  • Run Ghost persisting data to the ghost-data container
  • Update config.js in /var/lib/ghost to point to your cloudhero.io site

Creating the Ghost Site with a Persistent Store

Connect the local docker commands to administer docker on the cloudhero.io cluster:
eval $(curl -s https://portal.cloudhero.io/bootstrap/.../script | sh)
docker create -v /var/lib/ghost --name ghost-data ghost /bin/true
docker run --name ghost -p 80:2368 --volumes-from ghost-data -d ghost

Configure the persistent store

docker exec -it ghost /bin/bash
Get your node name from cloudhero.io, under the account tab. Change config.js to point to http://swarmXXXX.cloudhero.io, restart to pick up the config.
docker restart ghost

Put stuff on your website

open http://swarm1398.cloudhero.io/ghost
Create your login:
Your@email.com, your real (or pen) name.
Continue by adding new posts, etc.

Backup data from ghost-data container

It's pretty hard to get access to the host filesystem from within a container. The simplest way to deal with this is to use an external place to store the data. Accessing the local filesystem from within a container is difficult, using plain hold SCP does the trick.
docker stop ghost
docker run -it --volumes-from ghost-data ghost /bin/bash
Inside the container:
apt-get update;apt-get install -y openssh-client
tar zcf /tmp/ghost.tgz /var/lib/ghost
scp /tmp/ghost.tgz login@useful-stuff.info:.

Get data from backup and store it locally

scp login@useful-stuff.info:ghost.tgz .
Restart container
docker start ghost
How Do I Setup A Free Website Using Docker?
Share this