GitLab Docker Images
GitLab Docker Images
Prerequisites
Docker installation is required, see the official installation docs.
Note: Using a native Docker install instead of Docker Toolbox is recommended in order to use the
persisted volumes
This will download and start a GitLab CE container and publish ports needed to access SSH, HTTP
and HTTPS. All GitLab data will be stored as subdirectories of /srv/gitlab/. The container
will automatically restart after a system reboot.
You can now login to the web interface as explained in After starting a container.
If you are on SELinux then run this instead:
sudo docker run --detach \
--hostname gitlab.example.com \
--publish 443:443 --publish 80:80 --publish 22:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab:Z \
--volume /srv/gitlab/logs:/var/log/gitlab:Z \
--volume /srv/gitlab/data:/var/opt/gitlab:Z \
gitlab/gitlab-ce:latest
This will ensure that the Docker process has enough permissions to create the config files in the
mounted volumes.
Configure GitLab
This container uses the official Omnibus GitLab package, so all configuration is done in the unique
configuration file /etc/gitlab/gitlab.rb.
To access GitLab's configuration file, you can start a shell session in the context of a running
container. This will allow you to browse all directories and use your favorite text editor:
sudo docker exec -it gitlab /bin/bash
Once you open /etc/gitlab/gitlab.rb make sure to set the external_url to point to a
valid URL.
To receive e-mails from GitLab you have to configure the SMTP settings because the GitLab
Docker image doesn't have an SMTP server installed.
You may also be interested in Enabling HTTPS.
After you make all the changes you want, you will need to restart the container in order to
reconfigure GitLab:
sudo docker restart gitlab
Here's an example that sets the external URL and enables LFS while starting the container:
sudo docker run --detach \
--hostname gitlab.example.com \
--env GITLAB_OMNIBUS_CONFIG="external_url 'http://my.domain.com/';
gitlab_rails['lfs_enabled'] = true;" \
--publish 443:443 --publish 80:80 --publish 22: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
Note that every time you execute a docker run command, you need to provide the
GITLAB_OMNIBUS_CONFIG option. The content of GITLAB_OMNIBUS_CONFIG is not
preserved between subsequent runs.
There are also a limited number of environment variables to configure GitLab. They are
documented in the environment variables section of the GitLab documentation.
You can then access your GitLab instance at http://1.1.1.1/ and https://1.1.1.1/.
Warning: Do NOT use port 8080 otherwise there will be conflicts. This port is already
used by Unicorn that runs internally in the container.
If you want to use a different port than 80 (HTTP) or 443 (HTTPS) for the container, you need to
add a separate --publish directive to the docker run command.
For example, to expose the web interface on port 8929, and the SSH service on port 2289, use the
following docker run command:
sudo docker run --detach \
--hostname gitlab.example.com \
--publish 8929:80 --publish 2289: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
1. Set external_url:
# For HTTP
external_url "http://gitlab.example.com:8929"
or
Following the above example you will be able to reach GitLab from your web browser under
<hostIP>:8929 and push using SSH under the port 2289.
A docker-compose.yml example that uses different ports can be found in the docker-compose
section.
3. Make sure you are in the same directory as docker-compose.yml and run docker-
compose up -d to start GitLab
Troubleshooting
500 Internal Error
When updating the Docker image you may encounter an issue where all paths display the infamous
500 page. If this occurs, try to run sudo docker restart gitlab to restart the container
and rectify the issue.
Permission problems
When updating from older GitLab Docker images you might encounter permission problems. This
happens due to a fact that users in previous images were not preserved correctly. There's script that
fixes permissions for all files.
To fix your container, simply execute update-permissions and restart the container
afterwards:
sudo docker exec gitlab update-permissions
sudo docker restart gitlab
Getting help
If your problem is not listed here please see getting help for the support channels.
These docker images are officially supported by GitLab Inc. and should always be up to date.
1. docker is the default group, if you've changed this, update your commands accordingly.