Skip to content

Instantly share code, notes, and snippets.

@bekce
Last active September 16, 2015 19:56
Show Gist options
  • Select an option

  • Save bekce/40cf77cb5fe38f76cb07 to your computer and use it in GitHub Desktop.

Select an option

Save bekce/40cf77cb5fe38f76cb07 to your computer and use it in GitHub Desktop.
Gitlab basic cookbook

Use gitlab with a docker container. This guide is vastly learned from this reference document: https://gitlab.com/gitlab-org/gitlab-ce/tree/master/docker

However there are some more ideas and gotchas, so I decided to write this gist.

Start by creating & running our container. Replace ports (host:container) as desired.

sudo docker run --detach \
    --publish 8443:443 --publish 8080:80 --publish 2222:22 \
    --name gitlab \
    --restart always \
    --volume /srv/gitlab/config:/etc/gitlab \
    --volume /srv/gitlab/logs:/var/log/gitlab \
    --volume /srv/gitlab/data:/var/opt/gitlab \
    gitlab/gitlab-ce:latest

Drop into bash in your container. There is a little trick with the TERM variable.

docker exec -it gitlab /bin/bash -c "export TERM=xterm; exec bash"

Edit gitlab configuration file inside the container:

nano /etc/gitlab/gitlab.rb

Change external_url parameter to desired external base url. Note that this will be used to generate clone links and links in emails. Example: http://server:8080

Note that serving from relative url (like http://server/gitlab) is not implemented in omnibus gitlab distro -as of now- so it will not work if a relative path is given in this parameter. You can work this out with your nginx multi domain configuration skills:

Just simply configure an nginx (or apache) server on the host which runs at port 80 (naturally). Make up another name for your server (gitlab.company.com), register dns and configure this domain with nginx's proxy_pass to localhost:8080 where gitlab is running, voila!

listen_port is the container's internal port, which is mapped to 8080 of the host, so it must be 80.

external_url 'http://localhost:8080'
nginx['listen_port'] = 80

Also set other interesting settings such as email settings. See the reference for detailed information.

docker restart gitlab

Default login is root:5iveL!fe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment