# Setting up GitLab with Docker ### Useful commands: ``` sudo docker ps sudo docker image ls ``` * Edit container: ``` sudo docker exec -it gitlab /bin/bash ``` ### Starting point * Pre-installed Ubuntu 16.04 Desktop in Virtual Box ### Set up the repository * Update the apt package index: ``` sudo apt-get update ``` * Install packages to allow apt to use a repository over HTTPS: ``` sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common ``` * Add Docker's official GPG key: ``` curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - ``` * Set up stable repository: ``` sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" ``` ### Install Docker CE * Update the apt package index: ``` sudo apt-get update ``` * Install Docker ce latest version: ``` sudo apt-get install docker-ce ``` * Verify that Docker CE is working by running hello-world image: ``` sudo docker run hello-world ``` ### Install Docker Compose on Linux * Download Docker Compose: ``` sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose ``` * Apply excecutable permissions to the binary: ``` sudo chmod +x /usr/local/bin/docker-compose ``` * Test the installation: ``` sudo docker-compose --version ``` ### Install GitLab using docker-compose * Create docker-compose.yml file: ``` sudo nano docker-compose.yml ``` * Insert to file (remember to edit extrenal_url!): ``` web: image: 'gitlab/gitlab-ee:latest' restart: always hostname: '' environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http://YOUR IP HERE' # Add any other gitlab.rb configuration here, each on its own line ports: - '80:80' - '443:443' - '22:22' volumes: - '/srv/gitlab/config:/etc/gitlab' - '/srv/gitlab/logs:/var/log/gitlab' - '/srv/gitlab/data:/var/opt/gitlab' ``` * To start GitLab run the following command in same folder where docker-compose.yml is: ``` sudo docker-compose up -d ``` :exclamation: You need to have included ports free for this configuration to work. Common problem: SSH is on port 22 by default.