Dockerizing Services

After seeing Jess Fraz’s posts about home labs, I got more excited about finishing cleaning up my server and getting it a bit more modernized. When I first installed it I choose centos as a recommendation of a friend, and while its fine, I just know ubuntu/debian based systems a lot better and makes some of the random day to day tasks a lot easier.

I didn’t want to start completely from scratch again. I’ve done it a few times, and tried out setting up my systems using ansible, puppet, chef, etc but never kept it up to date enough to make moving to a new system easy.

I’ve tried installing kubernetes and docker swarm a few times over the years so my system is a mess, so I’ve just been sticking with docker + systemd to run my services. This will let me completely reinstall my base system in the future without having to reconfigure all the various services I want running. (Externally mounted volumes <3)

I’ll try to do follow up posts on pihole/dnssec/dnscrypt, jenkins, how awesome openvpn is.

Systemd + Tshock + Docker

I’ve been diving pretty head long into running services with docker. I’ve ported someone’s mineos and patched it to run in docker with a custom set of users. I have factorio server running. Even openhab running my meager home automation setup. Its the easiest way to run an application and not worry about system depaendancies.

Most of the time its pretty straight forward. docker run, walk away.

Tshock/Terraria gave me a bunch of trouble. It requires a working stdin, which none of my other daemonized processes do.

A bunch of digging and trial and error, I found out about the tty functionality for services. Which worked perfectly, but once I first logged in, it was causing my server to beep endlessly. I suspect tshock was sending terminal control codes.

Did a bit more reading. Found out you can have input from a tty, but output to the journal as normal. SUCCESS!

So for people like me that want to run tshock this way, here’s my systemd service file:


# needed because tshock crashes when no stdin
# Hijack tty11 for this purpose
# all output should stay in the journal though
ExecStartPre=-/usr/bin/docker stop terraria
ExecStartPre=-/usr/bin/docker rm terraria
ExecStop=/usr/bin/docker stop terraria
ExecStart=/usr/bin/docker run --rm -it \
        -p 7777:7777 \
        -v /storage/games/terraria/world:/world \
        --name terraria \
        ryshe/terraria:latest \
        -autocreate 3  \
        -world /world/Lg-Normal-17-02.wld