How to host your private git service inside Docker


Docker and Git are basically everywhere these days. In this blog post I will demonstrate how to put up private git service and host it inside Docker container. So, let’s start.

Quite some time now, I am very satisfied with git service named Gogs. You can find installation and more info here: Gogs is 100% open source and free of charge. All source code is available under the MIT License on GitHub.

I have Docker installed on my machine (Windows 10, but of course you can try this basically on any Linux/Mac/… based machine as well).

Docker image and container installation

First let check my local Docker images:


As you can see, I don’t have any Gogs image with this git service. So, I need to pull it from Docker Hub with docker pull command , like this…


Let’s check my docker images now:


We can start docker container based on this image.


Here, docker run command is used with some parameters, -p -> port redirection, –name -> name of the container, and some other parameters.

My docker container should be ready and running, let’s check.

Gogs git service configuration

Now, that my docker container with Gogs service is running, I can configure it. I point my web browser to http:localhost:10080, and on the first access I need to fill some data in order to finish my installation. I need to define some basic stuff, like db access, app name, ssh ports and similar.


After successful installation, I create admin user.


All done, now I can log in into my Gogs web portal and administer my git service.

Test my docker hosted git service

Before I conclude my writings, I will create new git repository and do initial commit to see if everything is working as expected. In Gogs git web portal I create new git repository, i.e.:


Newly created repository created ok. I get all all the basic information, like shown below.


Now, I can clone repository to my local desktop…


and add some files to newly cloned repository, commit and push back to my git server.


Finally, I can check my git repository for my changes.


Voila, I have my Gogs git server hosted and running in my docker container. Awesome.


Here, I presented straightforward approach how to host private git server inside docker containers. This way git service is uniformed, simple, does not require VM Hypervisors, with relatively small footprint. Furthermore, it provides all benefits related to docker based hosting.

In any case, I am firm believer that code should be hosted on some serious cloud based source code hosting providers, like GitHub or Bitbucket. Sometimes this is not possible (e.g. company policy) and private git hosting is the only option. Here, one relative easy solution is presented.

Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.