Install gitlab on docker with systemd

1. Install docker

$ sudo apt-get install docker.io
$ sudo service docker start
# Add user into docker group to use docker command without sudo.
$ sudo adduser <username> docker

2. Pull gitlab community edition image

$ docker pull gitlab/gitlab-ce

3. Configure systemd service

[Unit]
Description=Gitlab in docker.
After=docker.service
Requires=docker.service

[Service]
Restart=always
ExecStartPre=-/usr/bin/docker rm gitlab-ce
ExecStart=/usr/bin/docker run --rm \
          --name gitlab-ce \
          --volume /srv/gitlab/config:/etc/gitlab \
          --volume /srv/gitlab/logs:/var/log/gitlab \
          --volume /srv/gitlab/data:/var/opt/gitlab \
          --publish 80:80 --publish 2222:22 \
          gitlab/gitlab-ce
ExecStop=/usr/bin/docker stop gitlab-ce

[Install]
WantedBy=local.target
$ sudo systemctl enable gitlab-docker

kjwon15

I'm a hacker, I want to improve life.

Leave a Reply

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

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.