Running a Go Git Server in Docker

Installing a Git server in docker is a relatively painless operation if you choose the software to install carefully. Gogs is a self hosted service easy to install, lightweight and open source. I outline here the steps I have followed to install Gogs in Docker.


There is already an official Docker image for gogs so we only need to pull it from Docker Hub.

# Pull image from Docker Hub.
$ docker pull gogs/gogs

Because Docker containers can be deleted, I prefer to store all the important data outside of Docker image.

# Create a directory to store the data
$ mkdir -p /var/gogs

Gogs uses two ports which need to be forwarded: the ssh server in port 22 and the web server in port 3000.

# Use `docker run` for the first time.
$ docker run --name=gogs -p 10022:22 -p 10080:3000 \
      -v /var/gogs:/data gogs/gogs

# Use `docker start` if you have stopped it.
$ docker start gogs


In order to configure the application we need to go to the following address in the browser Below the most important settings.

Database settings

Note that a database needs to be created prior to completing the setup process.

  • Database Type: PostgreSQL
  • Host:
  • User: gogs
  • Password: xxxxxxxx
  • Database name: gogs

General settings

It is a good idea as well to fill in details for email server and click on email notification.

The configuration is saved in a file in /data/gogs/conf/app.ini so these values can be modified later.

Full documentation of application settings can be found here.