This blog post is a very bad idea if you are doing this in your professional life. Nonetheless, this works perfectly for your low traffic and low impact website on your cheap vps.
I dont want to concern myself with connecting to vpn, logging in on my vps, stopping an docker image, pulling a new docker image, starting the image again. It is very boring to do for each change you make.
Docker orchestration engines, like kubernetes, are way to big to host on my vps. A few docker images don’t need automated orchestration, I have no scaling option.
So some prerequisits:
- Single host
- Low traffic and low impact website
- Docker compose
It is easy, and it is ugly. Managing your docker container with dockercompose, adding it as a service to systemctl, and restarting it nightly.
Step 1, docker-compose your image
Create a docker-compose.yml with the following contents:
Easy as such, it pulls your image from docker hub, and runs it.
Step 2, create a service config
This makes sure your docker image could be run as a service, which makes it easier to manage on your command line.
Create a file called website.service in /lib/systemd/system
Reload the daemon
Your service should now be available, test it!
Your website should now run as a service!
Step 3, automate “deployment”
This is the lamest solution ever, but if it works, is it lame?
Edit your crontab, and add the line:
Each midnight it will pull the latest docker image, and enable it.
There we have it, Simple Automated docker deployment for barbarians