Docker Community Forums

Share and learn in the Docker community.

Two gitlab server on one Docker

Hello i want to create two gitlab servers on one docker!

for example:

sudo docker run --detach \
  --hostname gitlab.server1.com \
  --publish 1443:443 --publish 1080:80 --publish 1022:22 \
  --name gitlab-server1 \
  --restart always \
  --volume $GITLAB_HOME/config:/etc/gitlab \
  --volume $GITLAB_HOME/logs:/var/log/gitlab \
  --volume $GITLAB_HOME/data:/var/opt/gitlab \
  gitlab/gitlab-ee:latest
sudo docker run --detach \
  --hostname gitlab.server2.com \
  --publish 2443:443 --publish 2080:80 --publish 2022:22 \
  --name gitlab-server2 \
  --restart always \
  --volume $GITLAB_HOME/config:/etc/gitlab \
  --volume $GITLAB_HOME/logs:/var/log/gitlab \
  --volume $GITLAB_HOME/data:/var/opt/gitlab \
  gitlab/gitlab-ee:latest

Is it necessary to change the the volume paths also and something else to take care?

Thank you in advance

You can fine tune these directories to meet your requirements. Once you’ve set up the GITLAB_HOME variable, you can run the image:

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
gitlab/gitlab-ee:latest

This will download and start a GitLab container and publish ports needed to access SSH, HTTP and HTTPS. All GitLab data will be stored as subdirectories of $GITLAB_HOME. The container will automatically restart after a system reboot.

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 $GITLAB_HOME/config:/etc/gitlab:Z
–volume $GITLAB_HOME/logs:/var/log/gitlab:Z
–volume $GITLAB_HOME/data:/var/opt/gitlab:Z
gitlab/gitlab-ee:latest

This will ensure that the Docker process has enough permissions to create the config files in the mounted volumes.

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. The very first time you visit GitLab, you will be asked to set up the admin password. After you change it, you can login with username root and the password you set up.