Error executing action run on resource ruby_block[directory resource: /data/GitLab]
/dev/shm
mount not having enough space in Docker container
json-file
Find the GitLab official Docker image at:
The Docker images don’t include a mail transport agent (MTA). The recommended solution is to add an MTA (such as Postfix or Sendmail) running in a separate container. As another option, you can install an MTA directly in the GitLab container, but this adds maintenance overhead as you’ll likely need to reinstall the MTA after every upgrade or restart.
In the following examples, if you want to use the latest RC image, use
gitlab/gitlab-ee:rc
instead.
You should not deploy the GitLab Docker image in Kubernetes as it creates a single point of failure. If you want to deploy GitLab in Kubernetes, the GitLab Helm Chart or GitLab Operator should be used instead.
Docker is required. See the official installation documentation .
For Linux users, set the path to
/srv/gitlab
:
For macOS users, use the user’s
$HOME/gitlab
directory:
The GitLab container uses host mounted volumes to store persistent data:
Local location | Container location | Usage |
---|---|---|
$GITLAB_HOME/data
|
/var/opt/gitlab
|
For storing application data. |
$GITLAB_HOME/logs
|
/var/log/gitlab
|
For storing logs. |
$GITLAB_HOME/config
|
/etc/gitlab
|
For storing the GitLab configuration files. |
The GitLab Docker images can be run in multiple ways:
If you are on SELinux, then run this instead:
If you’re using the
Kerberos integration
,
you must also publish your Kerberos port (for example,
--publish 8443:8443
).
Failing to do so prevents Git operations with Kerberos.
The initialization process may take a long time. You can track this process with:
sudo docker logs -f gitlab
After starting a container you can visit
gitlab.example.com
(or
http://192.168.59.103
if you used boot2docker on macOS). It might take a while
before the Docker container starts to respond to queries.
Visit the GitLab URL, and sign in with the username
root
and the password from the following command:
sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
The password file will be automatically deleted in the first reconfigure run after 24 hours.
Install GitLab using Docker Compose
With
Docker Compose
you can easily configure,
install, and upgrade your Docker-based GitLab installation:
Install Docker Compose
.
-
Create a
docker-compose.yml
file:
version: '3.6'
services:
web:
image: 'gitlab/gitlab-ee:latest'
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.example.com'
# Add any other gitlab.rb configuration here, each on its own line
ports:
- '80:80'
- '443:443'
- '22:22'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'
shm_size: '256m'
Make sure you are in the same directory as docker-compose.yml
and start
GitLab:
docker compose up -d
Read the “Pre-configure Docker container” section
to see how the GITLAB_OMNIBUS_CONFIG
variable works.
Below is another
docker-compose.yml
example with GitLab running on a custom
HTTP and SSH port. Notice how the
GITLAB_OMNIBUS_CONFIG
variables match the
ports
section:
version: '3.6'
services:
web:
image: 'gitlab/gitlab-ee:latest'
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.example.com:8929'
gitlab_rails['gitlab_shell_ssh_port'] = 2224
ports:
- '8929:8929'
- '2224:22'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'
shm_size: '256m'
This is the same as using
--publish 8929:8929 --publish 2224:22
.
Install GitLab using Docker swarm mode
With
Docker swarm mode
, you can easily
configure and deploy your
Docker-based GitLab installation in a swarm cluster.
In swarm mode you can leverage
Docker secrets
and
Docker configurations
to efficiently and securely deploy your GitLab instance.
Secrets can be used to securely pass your initial root password without exposing it as an environment variable.
Configurations can help you to keep your GitLab image as generic as possible.
Here’s an example that deploys GitLab with four runners as a
stack
, using secrets and configurations:
Set up a Docker swarm
.
-
Create a
docker-compose.yml
file:
version: "3.6"
services:
gitlab:
image: gitlab/gitlab-ee:latest
ports:
- "22:22"
- "80:80"
- "443:443"
volumes:
- $GITLAB_HOME/data:/var/opt/gitlab
- $GITLAB_HOME/logs:/var/log/gitlab
- $GITLAB_HOME/config:/etc/gitlab
shm_size: '256m'
environment:
GITLAB_OMNIBUS_CONFIG: "from_file('/omnibus_config.rb')"
configs:
- source: gitlab
target: /omnibus_config.rb
secrets:
- gitlab_root_password
gitlab-runner:
image: gitlab/gitlab-runner:alpine
deploy:
mode: replicated
replicas: 4
configs:
gitlab:
file: ./gitlab.rb
secrets:
gitlab_root_password:
file: ./root_password.txt
For simplicity reasons, the
network
configuration was omitted.
More information can be found in the official
Compose file reference
.
-
Create a
gitlab.rb
file:
external_url 'https://my.domain.com/'
gitlab_rails['initial_root_password'] = File.read('/run/secrets/gitlab_root_password').gsub("\n", "")
Create a root_password.txt
file:
MySuperSecretAndSecurePassw0rd!
Make sure you are in the same directory as docker-compose.yml
and run:
docker stack deploy --compose-file docker-compose.yml mystack
Install the product documentation
This is an optional step. See how to
self-host the product documentation
.
Configuration
You can also just edit
/etc/gitlab/gitlab.rb
:
Once you open
/etc/gitlab/gitlab.rb
make sure to set the
external_url
to
point to a valid URL.
To receive emails 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 to reconfigure GitLab:
sudo docker restart gitlab
GitLab will reconfigure itself whenever the container starts.
For more options about configuring GitLab, check the
configuration documentation
.
Pre-configure Docker container
You can pre-configure the GitLab Docker image by adding the environment variable
GITLAB_OMNIBUS_CONFIG
to Docker run command. This variable can contain any
gitlab.rb
setting and is evaluated before the loading of the container’s
gitlab.rb
file. This behavior allows you to configure the external GitLab URL,
and make database configuration or any other option from the
Omnibus GitLab template
.
The settings contained in
GITLAB_OMNIBUS_CONFIG
aren’t written to the
gitlab.rb
configuration file, and are evaluated on load.
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 $GITLAB_HOME/config:/etc/gitlab \
--volume $GITLAB_HOME/logs:/var/log/gitlab \
--volume $GITLAB_HOME/data:/var/opt/gitlab \
--shm-size 256m \
gitlab/gitlab-ee:latest
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.
Use tagged versions of GitLab
Tagged versions of the GitLab Docker images are also provided.
To see all available tags see:
To use a specific tagged version, replace
gitlab/gitlab-ee:latest
with
the GitLab version you want to run, for example
gitlab/gitlab-ee:12.1.3-ce.0
.
Run GitLab on a public IP address
To expose GitLab on IP
198.51.100.1
:
You can then access your GitLab instance at
http://198.51.100.1/
and
https://198.51.100.1/
.
Expose GitLab on different ports
GitLab will occupy
some ports
inside the container.
If you want to use a different host port than
80
(HTTP) or
443
(HTTPS),
you need to add a separate
--publish
directive to the
docker run
command.
For example, to expose the web interface on the host’s 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:8929 --publish 2289:22 \
--name gitlab \
--restart always \
--volume $GITLAB_HOME/config:/etc/gitlab \
--volume $GITLAB_HOME/logs:/var/log/gitlab \
--volume $GITLAB_HOME/data:/var/opt/gitlab \
--shm-size 256m \
gitlab/gitlab-ee:latest
The format for publishing ports is hostPort:containerPort
. Read more in the
Docker documentation about
exposing incoming ports.
-
Enter the running container:
sudo docker exec -it gitlab /bin/bash
Open /etc/gitlab/gitlab.rb
with your editor and set external_url
:
# For HTTP
external_url "http://gitlab.example.com:8929"
# For HTTPS (notice the https)
external_url "https://gitlab.example.com:8929"
The port specified in this URL must match the port published to the host by Docker.
Additionally, if the NGINX listen port is not explicitly set in
nginx['listen_port']
, it will be pulled from the external_url
.
For more information see the NGINX documentation.
-
Set
gitlab_shell_ssh_port
:
gitlab_rails['gitlab_shell_ssh_port'] = 2289
Finally, reconfigure GitLab:
gitlab-ctl reconfigure
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.
Configure multiple database connections
If you want to opt-in for this feature:
Upgrade
In most cases, upgrading GitLab is as easy as downloading the newest Docker
image tag
.
Upgrade GitLab using Docker Engine
To upgrade GitLab that was
installed using Docker Engine
:
Take a
backup
. As a minimum, back up
the database
and
the GitLab secrets file.
-
Stop the running container:
sudo docker stop gitlab
Remove the existing container:
sudo docker rm gitlab
Pull the new image. For example, the latest GitLab image:
sudo docker pull gitlab/gitlab-ee:latest
Create the container once again with the
previously specified options:
sudo docker run --detach \
--hostname gitlab.example.com \
--publish 443:443 --publish 80:80 --publish 22:22 \
--name gitlab \
--restart always \
--volume $GITLAB_HOME/config:/etc/gitlab \
--volume $GITLAB_HOME/logs:/var/log/gitlab \
--volume $GITLAB_HOME/data:/var/opt/gitlab \
--shm-size 256m \
gitlab/gitlab-ee:latest
On the first run, GitLab will reconfigure and upgrade itself.
Refer to the GitLab
Upgrade recommendations
when upgrading between major versions.
Upgrade GitLab using Docker compose
To upgrade GitLab that was
installed using Docker Compose
:
Take a
backup
. As a minimum, back up
the database
and
the GitLab secrets file.
-
Download the newest release and upgrade your GitLab instance:
docker compose pull
docker compose up -d
If you have used
tags
instead, you’ll need
to first edit
docker-compose.yml
.
Convert Community Edition to Enterprise Edition
You can convert an existing Docker-based GitLab Community Edition (CE) container
to a GitLab
Enterprise Edition
(EE) container
using the same approach as
upgrading the version
.
We recommend you convert from the same version of CE to EE (for example, CE 14.1 to EE 14.1).
This is not explicitly necessary, and any standard upgrade (for example, CE 14.0 to EE 14.1) should work.
The following steps assume that you are upgrading the same version.
Take a
backup
. As a minimum, back up
the database
and
the GitLab secrets file.
-
Stop the current CE container, and remove or rename it.
-
To create a new container with GitLab EE,
replace
ce
with
ee
in your
docker run
command or
docker-compose.yml
file.
However, reuse the CE container name, port and file mappings, and version.
Upgrade the product documentation
This is an optional step. If you
installed the documentation site
,
see how to
upgrade to another version
.
Downgrade GitLab
To downgrade GitLab after an upgrade:
Follow the upgrade procedure, but
specify the tag for the original version of GitLab
instead of
latest
.
-
Restore the
database backup you made
as part of the upgrade.
-
Restoring is required to back out database data and schema changes (migrations) made as part of the upgrade.
-
GitLab backups must be restored to the exact same version and edition.
-
Follow the restore steps for Docker images
, including
stopping Puma and Sidekiq. Only the database must be restored, so add
SKIP=artifacts,repositories,registry,uploads,builds,pages,lfs,packages,terraform_state
to the
gitlab-backup restore
command line arguments.
Back up GitLab
You can create a GitLab backup with:
Read more on how to
back up and restore GitLab
.
If configuration is provided entirely via the
GITLAB_OMNIBUS_CONFIG
environment variable
(per the
“Pre-configure Docker Container”
steps),
meaning no configuration is set directly in the
gitlab.rb
file, then there is no need
to back up the
gitlab.rb
file.
Backing up the GitLab secrets file
is required
to avoid
complicated steps
when recovering
GitLab from backup. The secrets file is stored at
/etc/gitlab/gitlab-secrets.json
inside the container, or
$GITLAB_HOME/config/gitlab-secrets.json
on the container host
.
Create a database backup
A database backup is required to roll back GitLab upgrade if you encounter issues.
The backup is written to
/var/opt/gitlab/backups
which should be on a
volume mounted by Docker
.
Installing GitLab Community Edition
To install the Community Edition, replace
ee
with
ce
in the commands on this
page.
Troubleshooting
The following information will help if you encounter problems using Omnibus GitLab and Docker.
Diagnose potential problems
From within the container you can administer the GitLab container as you would
usually administer an
Omnibus installation
500 Internal Error
Permission problems
To fix your container, execute
update-permissions
and restart the
container afterwards:
Windows/Mac:
Error executing action run on resource ruby_block[directory resource: /data/GitLab]
Linux ACL issues
If these are not correct, set them with:
The default group is
docker
. If you changed the group, be sure to update your
commands.
/dev/shm
mount not having enough space in Docker container
Docker containers exhausts space due to the
json-file
Docker uses the
json-file
default logging driver
, which performs no log rotation by default. As a result of this lack of rotation, log files stored by the
json-file
driver can consume a significant amount of disk space for containers that generate a lot of output. This can lead to disk space exhaustion. To address this, use
journald
as the logging driver when available, or
another supported driver
with native rotation support.
Buffer overflow error when starting Docker
If you receive this buffer overflow error, you should purge old log files in
/var/log/gitlab
:
Removing old log files helps fix the error, and ensures a clean startup of the instance.
Help & feedback
Docs
Edit this page
to fix an error or add an improvement in a merge request.
Create an issue
to suggest an improvement to this page.
Product
Create an issue
if there's something you don't like about this feature.
Propose functionality
by submitting a feature request.
Join First Look
to help shape new features.
Feature availability and product trials
View pricing
to see all GitLab tiers and features, or to upgrade.
Try GitLab for free
with access to all features for 30 days.
Get Help
If you didn't find what you were looking for,
search the docs
.
If you want help with something specific and could use community support,
post on the GitLab forum
.
For problems setting up or using this feature (depending on your GitLab
subscription).
Request support