Use Docker to deploy Gitlab and docker to deploy gitlab

Source: Internet
Author: User
Tags ssh access

Use Docker to deploy Gitlab and docker to deploy gitlab

The company's code server has been built using Gitosis, but it is too troublesome to manage users and permissions,
Now we want to build Gitlab on the original server and install it directly using the official Gitlab method,
This will cause a conflict with Gitosis, making Gitosis unavailable,
To keep the two services at the same time, we thought of using Docker to build Gitlab.

The following uses Ubuntu 14.04 as an example to install Docker and Gitlab.

Install Docker

Enter a command in bash to install the latest docker

sudo apt-get purge docker.iocurl -s https://get.docker.io/ubuntu/ | sudo shsudo apt-get updatesudo apt-get install lxc-docker
Download Image

The following script downloads the gitlab, mysql, and redis images.

docker pull sameersbn/gitlab:latestdocker pull sameersbn/mysql:latest docker pull sameersbn/redis:latest
Start redis
docker run \  --name=gitlab_redis \  -tid \  sameersbn/redis:latest
Start mysql
mkdir -p /opt/gitlab/mysqldocker run \  --name=gitlab_mysql \  -tid \  -e 'DB_NAME=gitlabhq_production' \  -e 'DB_USER=gitlab' \  -e 'DB_PASS=password' \  -v /opt/gitlab/mysql:/var/lib/mysql \  sameersbn/mysql:latest
Start gitlab
mkdir -p /opt/gitlab/data /opt/gitlab/logdocker run \  --name='gitlab' \  -itd \  --link gitlab_mysql:mysql \  --link gitlab_redis:redisio \  -e 'GITLAB_PORT=80' \  -e 'GITLAB_SSH_PORT=22' \  -p 10022:22 -p 10080:80 \  -v /var/run/docker.sock:/run/docker.sock \  -v $(which docker):/bin/docker \  -v /opt/gitlab/data:/home/git/data \  -v /opt/gitlab/log:/var/log/gitlab \  sameersbn/gitlab:latest

This step takes several minutes because some initialization operations are performed in this step. We can view the installation process through docker logs gitlab.
We specified 10022 as the ssh access port and 10080 as the http access port,

After the execution, you can access gitlab at the following address after 1-2 minutes.
Http: // localhost: 10080
If it is set up on the server, replace localhost with the server address.

Add boot start

Add/etc/rc. local

echo 'docker start gitlab_redis' >> /etc/rc.localecho 'docker start gitlab_mysql' >> /etc/rc.localecho 'docker start gitlab' >> /etc/rc.local
How to enter the server in docker
  • If you are using Docker 1.3.0 or later, run the following command:
docker exec -it gitlab bash
  • To use an older version, run the following command:
docker run --rm --volume=/usr/local/bin:/target jpetazzo/nsentersudo docker-enter gitlab
Back up and restore gitlab
  • Backup
docker stop gitlab && docker rm gitlabdocker run --name=gitlab -it --rm [OPTIONS] \  sameersbn/gitlab:latest app:rake gitlab:backup:create
  • Restore
docker stop gitlab && docker rm gitlabdocker run --name=gitlab -it --rm [OPTIONS] \  sameersbn/gitlab:latest app:rake gitlab:backup:restore
Upgrade gitlab
  • Retry the pull gitlab Image
docker pull sameersbn/gitlab:7.11.4
  • Stop and delete the current gitlab Process
docker stop gitlabdocker rm gitlab
  • Restart gitlab
docker run \  --name='gitlab' \  -itd \  --link gitlab_mysql:mysql \  --link gitlab_redis:redisio \  -e 'GITLAB_PORT=80' \  -e 'GITLAB_SSH_PORT=22' \  -p 10022:22 -p 10080:80 \  -v /var/run/docker.sock:/run/docker.sock \  -v $(which docker):/bin/docker \  -v /opt/gitlab/data:/home/git/data \  -v /opt/gitlab/log:/var/log/gitlab \  sameersbn/gitlab:latest

Author: Yangchun noodle
Source: http://www.aswifter.com/2015/06/14/gitlab-with-docker/
For reprinting, please indicate the source of this article at the beginning.

Welcome to my public account, share Swift development, Android development, and Internet content
No.: APP developer

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.