Everybody knows gitHub, ok, but today, We will install another competitor (From Google, I’m sure you know it !) : Gogs.


Let’start with any CentOS 7.x Linux distribution (mine is CentOS 7.2 runing as a virtual machine hosted on a XenServer 6.5 host).

[root@docker ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

Install Docker

Yes, by now, I prefer using Docker containers …

It’s really simple :

[root@docker ~]# curl -fsSL https://get.docker.com/ | bash
+ sh -c 'sleep 3; yum -y -q install docker-engine'
warning: /var/cache/yum/x86_64/7/docker-main-repo/packages/docker-engine-selinux-1.11.2-1.el7.centos.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY
Public key for docker-engine-selinux-1.11.2-1.el7.centos.noarch.rpm is not installed
Importing GPG key 0x2C52609D:
 Userid     : "Docker Release Tool (releasedocker) <docker@docker.com>"
 Fingerprint: 5811 8e89 f3a9 1289 7c07 0adb f762 2157 2c52 609d
 From       : https://yum.dockerproject.org/gpg
restorecon:  lstat(/var/lib/docker) failed:  No such file or directory
warning: %post(docker-engine-selinux-1.11.2-1.el7.centos.noarch) scriptlet failed, exit status 255
Non-fatal POSTIN scriptlet failure in rpm package docker-engine-selinux-1.11.2-1.el7.centos.noarch

If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

Remember that you will have to log out and back in for this to take effect!

Start Docker service :

[root@docker ~]# systemctl start docker

And keep it started on a next reboot :

[root@docker ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

Our docker installation looks good :

[root@docker ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
a9d36faac0fe: Pull complete
Digest: sha256:e52be8ffeeb1f374f440893189cd32f44cb166650e7ab185fa7735b7dc48d619
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:

For more examples and ideas, visit:


Download MariaDB Docker image :

[root@docker ~]# docker pull mariadb

Start MariaDB container :

[root@docker ~]# docker run --name MariaDB -e MYSQL_ROOT_PASSWORD=your_password -d mariadb

Create a dadabase for Gogs :

[root@docker ~]# docker exec -it MariaDB bash
root@b8c01a9d244a:/# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.14-MariaDB-1~jessie mariadb.org binary distribution

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database gogs;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> quit
root@b8c01a9d244a:/# exit

Create a new filesystem to contain data

Using XenCenter, we add a new virtual drive.

This new drive has been created (XenServer Tools ?) :

[root@docker ~]# lsblk -f
NAME                         FSTYPE      LABEL UUID                                   MOUNTPOINT
├─xvda1                      xfs               a19f05de-5566-40c4-82d2-10fd4cdc9910   /boot
└─xvda2                      LVM2_member       IK0mzQ-wTXL-nhD1-e6q9-4xUP-qMHd-cfAqL4
  ├─centos-root              xfs               7cca21b7-bd02-4a19-b97a-f6dd1a918e1a   /
  └─centos-swap              swap              0eacd7e9-776d-434f-a5d5-1e06d477ca53   [SWAP]

Create a full partition on this drive :

[root@docker ~]# parted -s /dev/xvdb mklabel gpt
[root@docker ~]# parted -s /dev/xvdb mkpart primary xfs 0% 100%

Create an XFS filesystem :

[root@docker ~]# mkfs.xfs /dev/xvdb1
meta-data=/dev/xvdb1             isize=256    agcount=4, agsize=130944 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=523776, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

It’s time to mount this filesystem :

  • Create a mount point :
[root@docker ~]# mkdir /gogs/data
  • Add an entry in “/etc/fstab” :
[root@docker ~]# grep /data /etc/fstab
/dev/xvdb1      /gogs/data   xfs     defaults        0       0
  • And mount this filesystem :
root@docker ~]# mount /gogs/data


Download Gogs docker image :

[root@docker ~]# docker pull gogs/gogs

My images is here :

[root@docker ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
gogs/gogs           latest              f6cdd266fdf5        7 days ago          84.58 MB
mariadb             latest              0112f2662974        9 days ago          387.6 MB
hello-world         latest              693bce725149        11 days ago         967 B

Start Gogs container :

[root@docker ~]# docker run --name=Gogs -p 10022:22 -p 10080:3000 -v /gogs/data:/data --link MariaDB:mysql -d gogs/gogs

Git account

Create “git” account with the same UID/GID Docker Gogs container uses :

[root@docker ~]# docker exec -it Gogs bash
bash-4.3# id git
uid=1000(git) gid=1000(git) groups=1000(git)
bash-4.3# exit

Within the container, both group “git” and user “git” exit (GID=1000 ; UID=1000), we will create them in Linux :

[root@docker ~]# groupadd -g 1000 git
[root@docker ~]# useradd -u 1000 -g 1000 git

Set “git” as the owner of this mount point :

[root@docker ~]# chown git:git /gogs/data

Configure firewalld

Open ports :

[root@docker ~]# firewall-cmd --permanent --add-port=10080/tcp
[root@docker ~]# firewall-cmd --permanent --add-port=10022/tcp

Apply rules :

[root@docker ~]# firewall-cmd --reload

Gogs configuration

Open a WEB browser to port 10080 :

Enter the password you set for MariaDB …

Go back to http://your_Linux_server:10080 page :















You can create an account :










Logon using this account, and create your first repository :











This repository has been created :








Intall “git” :

[root@docker ~]# yum -y install git

Download your first repository :

[wou@docker ~]$ git clone

 Cloning into 'my_NGINX'...
 warning: You appear to have cloned an empty repository.

Go to the directory :

[wou@docker ~]$ cd my_NGINX

Create “README” MarkDown format file :

[wou@docker my_NGINX]$ echo <<THE_END >README.md
 > My NGINX configuration files
 > ============================
 > <br>
 > I will put some files in this repository

Update the repository :

  • Add this file :
[wou@docker my_NGINX]$ git add README.md
  • Commit the change :
[wou@docker my_NGINX]$ git commit -m "first steep"
[master (root-commit) d7318a5] first steep
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
  • Then push :
[wou@docker my_NGINX]$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Username for '': wou
Password for 'http://wou@':
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
Everything up-to-date




en.pdf24.org    Send article as PDF   

Leave a Reply

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