Category Archives: Gogs

Hosting a github like service on my Ubuntu server

I was thinking it would be cool to host some private git repositories on my Ubuntu server. That’s where Gogs comes in.

Sure I could have created a git repository “manually” but why bother when Gogs comes in a docker instance as well (and I love Docker).

Excellent documentation is available on the Gogs website or via Docker for Gogs on GitHub. But I will be recreating the bare essentials here so I know what worked for me.

First off, we’re going to need to create a Docker volume. For those unfamiliar with Docker, data is stored in the instance of Docker and therefore lost when it shuts down. To allow data to persist beyond the life of the Docker instance, we create a Docker volume.

So first up, I just used the default Docker volume location using

docker volume create --name gogs-data

On my Ubuntu installation, this folder is created within /var/lib/docker.

Next up we’ll simply run

docker run --name=gogs -p 10022:22 -p 10080:3000 -v gogs-data:/data gogs/gogs

This command will download/install an instance of gogs and it will be available on port 10080 of the server. The instance will connect it’s data through to our previously created volume using the -v switch.

From your chosen web browser, you can display the Gogs configuration web page using http://your-server:10080.

As I didn’t have MySQL or PostgresSQL set-up at the time of installation, I simply chose SQLite from the database options shown on the configuration page.

That’s pretty much it – you’ll need to create a user login for your account and then you can start creating repositories.

I’m not sure if I’m doing something wrong, but I noticed that when you want to clone a repository, Gogs says I should clone

http://localhost:3000/mark/MyApp.git

Obviously localhost is no use from a remote machine and also 3000 seems to be incorrect, and should be 10080 (as specified in the run command).