Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Docker Gogs systemd script

Starting Gogs as a Docker container on startup via systemd

Gogs is that great Github clone which is also available as a docker image. Works perfectly if started by the user but since you probably want to run it on your server and without interruption you can add a systemd script to start up Gogs on boot. My script looks like this:

# /etc/systemd/system/docker.gogs.service
Description=Gogs container

ExecStart=/usr/bin/docker run --name=gogs -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs
ExecStop=/usr/bin/docker stop -t 2 gogs ; /usr/bin/docker rm -f gogs


This script expects to find docker and postgres running since those are the two dependencies.

It will always restart if it crashes and run on ports 10022 for ssh and 10088 for http. Data is stored under /var/data. If the container stops it is immediately purged and restarted.

In order to activate your script you need to:

sudo systemctl enable docker.gogs

You can now either just connect to your ip:10080 or set up a webserver backproxy so that you can easily integrate your service with other web services.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.