This documentation guides you through the process of deploying a GitLab instance using Docker Compose. GitLab is a complete DevOps platform that allows you to perform all the tasks required to develop software, from project planning and source code management to CI/CD, monitoring, and security. By deploying GitLab using Docker, you can ensure a consistent and isolated environment for your GitLab instance.
Prerequisites
docker-compose.yml file in directory. Replace environment variable placeholders (${VARIABLE_NAME}) with actual values before deployment.version: '3.6' services:
web:
image: 'gitlab/gitlab-ce:latest'
container_name: ${CONTAINER_NAME}
restart: always
hostname: ${HOST_NAME}
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url = "${EXTERNAL_URL_TRAEFIK}"
nginx['listen_port'] = 80
nginx['listen_https'] = false
registry['enable'] = false
gitlab_rails['gravatar_enabled'] = true
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "${SMTP_ADDRESS}"
gitlab_rails['smtp_port'] = ${SMTP_PORT}
gitlab_rails['smtp_user_name'] = "${SMTP_USERNAME}"
gitlab_rails['smtp_password'] = "${SMTP_PASSWORD}"
gitlab_rails['smtp_domain'] = "${SMTP_DOMAIN}"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls'] = true
gitlab_rails['smtp_openssl_verify_mode'] = "peer"
gitlab_rails['gitlab_email_from'] = "${GITLAB_EMAIL_FROM}"
gitlab_rails['gitlab_email_reply_to'] = "${GITLAB_EMAIL_TO}"
labels:
- "traefik.enable=true"
- "traefik.http.routers.gitlab.rule=Host(`${HOST_NAME}`)"
- "traefik.http.routers.gitlab.tls=true"
- "traefik.http.routers.gitlab.tls.certresolver=leresolver"
- "traefik.http.routers.gitlab.middlewares=security-headers@file"
- "traefik.http.services.gitlab.loadbalancer.server.port=80"
networks:
- proxy
- gitlab-network
volumes:
- './config:/etc/gitlab'
- './logs:/var/log/gitlab'
- './data:/var/opt/gitlab'
- '/var/run/docker.sock:/var/run/docker.sock'
networks:
proxy:
external: true
gitlab-network:
driver: bridge
docker-compose.yml.docker-compose up -d in your terminal. This command will start your GitLab instance in detached mode.HOST_NAME.Changes made to the GitLab setup to enable SSH connections on a non-standard port (666), instead of the default SSH port (22). The configuration involves adjustments to both the GitLab service and the Traefik reverse proxy to ensure secure access for repository operations via SSH.
docker-compose.yml was modified to include port 666 in the port mappings, ensuring that the Docker host forwards traffic on this port to the GitLab container.GITLAB_OMNIBUS_CONFIG environment variable was updated to set the gitlab_rails['gitlab_shell_ssh_port'] configuration option to 666, aligning the GitLab application configuration with the Docker and SSH service settingsssh -p 666 -T [username]@gitlab.smns-bw.org. git clone ssh:[username]@gitlab.smns-bw.org:666/path/to/repository.git''.
Successful execution of such commands without errors confirms that the GitLab SSH configuration is operational.