|
Gitlab company has been running in a virtual machine inside ovm, or version 6.7.5. Version a bit old, recent research docker, was trying to migrate to the docker container gitlab go. Find someone really has done gitlab the image, and sincere praise.
1 plan
planning:
A container runs gitlab
A container run MySQL, then link to the gitlab.
A container run Redis, and then link to the gitlab.
2 Installation gitlab
Let's run MySQL,
$ Sudo docker pull sameersbn / mysql: latest
Create mysql data directory on the host host.
$ Sudo mkdir -p / opt / mysql / data
Start MySQL container.
$ Sudo docker run --name mysql -d \
-v / opt / mysql / data: / var / lib / mysql \
sameersbn / mysql: latest
Connect to MySQL, modify authorization information
$ Sudo docker exec -it mysql bash
Create a database and authorization.
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET` utf8` COLLATE `utf8_unicode_ci`;
GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER \
. ON `gitlabhq_production` * TO 'gitlab'@'172.17.%.%' IDENTIFIED BY 'dbpassword';
FLUSH PRIVILEGES;
3 Configure redis
Pull image
$ Sudo docker pull sameersbn / redis: latest
run redis
sh $ sudo docker run --name = redis -d sameersbn / redis: latest
4 Gitlab
Pull the old version of the first back imagepull
$ Sudo docker pull sameersbn / gitlab: 6.7.5
Create a data directory
$ Sudo mkdir -p / opt / gitlab / data
This directory will be mapped to the / home / git / data directory window, so here to save all the data, be sure not to delete the content here.
Run gitlab container, set the container will be migration and other database operations.
$ Sudo docker run --name gitlab -i -t --rm --link mysql: mysql \
-e "DB_USER = gitlab" -e "DB_PASS = dbpassword" \
-e "DB_NAME = gitlabhq_production" \
-v / opt / gitlab / data: / home / git / data \
sameersbn / gitlab: 6.7.5 app: rake gitlab: setup
Run gitlab container
$ Sudo docker run --name gitlab -d -P --link mysql: mysql \
-e "DB_USER = gitlab" -e "DB_PASS = dbpassword" \
-e "DB_NAME = gitlabhq_production" \
-v / opt / gitlab / data: / home / git / data \
sameersbn / gitlab: 6.7.5
# Export Backup from the original in gitlab
$ Cd / home / git / gitlab
$ Sudo -u git -H bundle exec rake gitlab: backup: create RAILS_ENV = production
The exported file in the / home / git / gitlab / tmp / backups directory.
This document scp to docker gitlab that machine / opt / gitlab / data / backups
Log on to the container gitlab
$ Sudo docker exec -it gitlab bash
Run the following command in containers
$ Cd / home / git / gitlab
$ Sudo -u git -H bundle exec rake gitlab: backup: restore RAILS_ENV = production
$ Exit
This kind of data is all to the new gitlab up. You will find the same with the original.
Let's gitlab upgrade to the new version.
$ Sudo docker stop gitlab
$ Sudo docker rm gitlab
$ Sudo docker run --name gitlab -d -P --link mysql: mysql \
--link redis: redisio \
-e "DB_USER = gitlab" -e "DB_PASS = dbpassword" \
-e "DB_NAME = gitlabhq_production" \
-v / opt / gitlab / data: / home / git / data \
sameersbn / gitlab: latest
Configured, save it as an image.
$ Sudo docker commit -m "update gitlab.yml, change host, set timezone to BeiJing" -a "china-ops gitlab v7.9.4" 6af1d0739ae0 china-ops / gitlab: 7.9.4
My original idea was to modify the config / gitlab.yml, the good host, timezone and other changes, and then saved as a new image. Later found to modify the config / gitlab.yml is not effective, it will restore the default values after the restart container. After reading the document to know, hostname, etc. is controlled by the environment variable.
Use this image to start a container
$ Sudo docker run --name gitlab -d \
-p 80:80 -p 8443: 443 \
--link mysql: mysql \
--link redis: redisio \
-e "DB_USER = gitlab" -e "DB_PASS = dbpassword" \
-e "DB_NAME = gitlabhq_production" \
-e "GITLAB_HOST = gitlab.china-ops.com" \
-e "GITLAB_TIMEZONE = Beijing" \
-e 'GITLAB_BACKUPS = daily' \
-e "GITLAB_GRAVATAR_ENABLED = false" \
-v / opt / gitlab / data: / home / git / data \
china-ops / gitlab: 7.9.4
Parameters -e 'GITLAB_BACKUPS = daily' backup strategy, we set a day |
|
|
|