gitlab docker-compose笔记

来源:互联网 发布:mysql 添加外键约束 编辑:程序博客网 时间:2024/05/20 12:50

0x00:环境

docker的版本是升级后的。root@ubuntu:~# docker version && lsb_release -aClient: Version:      17.07.0-ce API version:  1.31 Go version:   go1.8.3 Git commit:   8784753 Built:        Tue Aug 29 17:43:06 2017 OS/Arch:      linux/amd64Server: Version:      17.07.0-ce API version:  1.31 (minimum version 1.12) Go version:   go1.8.3 Git commit:   8784753 Built:        Tue Aug 29 17:41:57 2017 OS/Arch:      linux/amd64 Experimental: falseNo LSB modules are available.Distributor ID: UbuntuDescription:    Ubuntu 14.04.5 LTSRelease:    14.04Codename:   trusty

0x01:安装 docker-compose docker-machine

root@ubuntu:~# curl -L https://github.com/docker/compose/releases/download/1.16.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-composeroot@ubuntu:~# curl -L https://github.com/docker/machine/releases/download/v0.12.2/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machineroot@ubuntu:~# chmod +x /tmp/docker-machine &&> sudo cp /tmp/docker-machine /usr/local/bin/docker-machine

0x02:问题

1/docker-compose up命令提示compose api版本不一致,先用export声明一个变量,root@ubuntu:~# docker-compose upERROR: client and server don't have same version (client : 1.21, server: 1.18)2/声明变量root@ubuntu:~# export COMPOSE_API_VERSION=1.18client and server don't have same version (client : 1.21, server: 1.18)3/这时不在提示上面的错误,但是提示如下错误,版本低于1.21.到此只能升级docker SDK 了。root@ubuntu:~# /usr/local/bin/docker-compose up/tmp/_MEIaNe0oM/docker/api/client.py:161: UserWarning: The minimum API version supported is 1.21, but you are using version 1.18. It is recommended you either upgrade Docker Engine or use an older version of Docker SDK for Python.Traceback (most recent call last):  File "bin/docker-compose", line 6, in <module>  File "compose/cli/main.py", line 68, in main  File "compose/cli/main.py", line 121, in perform_command  File "compose/cli/main.py", line 938, in up  File "compose/project.py", line 419, in up  File "compose/project.py", line 468, in initialize  File "compose/network.py", line 257, in initialize  File "compose/network.py", line 61, in ensure  File "compose/network.py", line 93, in inspect  File "site-packages/docker/utils/decorators.py", line 31, in wrapperdocker.errors.InvalidVersion: inspect_network is not available for version < 1.21Failed to execute script docker-compose

0x03:升级Docker SDK

这是搜到的一段Docker SDK升级的方法,直接粘贴执行即可。echo "Checking current linux and docker version" && sleep 3 && \docker version && lsb_release -aecho "Purge lxc" && sleep 3 && \apt-get autoremove --purge lxcecho "Purge lxc*" && sleep 3 && \apt-get purge lxc*echo "Cleaning apt list" && sleep 3 && \apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/*echo "Installing new docker version" && sleep 3 && \curl -sSL https://get.docker.com/ | sh升级完后由原来的1.21升级到API version:  1.31

0x04:问题

升级完后继续执行,还是提示如下错误root@ubuntu:~# docker-compose upinspect_network is not available for version < 1.21声明1.31.再次执行成功。root@ubuntu:~# export COMPOSE_API_VERSION=1.31等compose结束,gitlab安装完成;浏览器访问gitlabhttp://10.160.11.191:10080/users/confirmation/newdocker ps可以看到3个containerroot@ubuntu:~# docker psCONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                   NAMES0b76f966e4c3        sameersbn/gitlab:9.5.2       "/sbin/entrypoint...."   3 hours ago         Up 3 hours          443/tcp, 0.0.0.0:10022->22/tcp, 0.0.0.0:10080->80/tcp   root_gitlab_1897425f2c1c4        sameersbn/postgresql:9.6-2   "/sbin/entrypoint.sh"    3 hours ago         Up 3 hours          5432/tcp                                                root_postgresql_10d0ed81d053c        sameersbn/redis:latest       "/sbin/entrypoint...."   3 hours ago         Up 3 hours          6379/tcp                                                root_redis_1

0x05:gitlab Quick Start 方法

Quick StartThe quickest way to get started is using docker-compose.***wget https://raw.githubusercontent.com/sameersbn/docker-gitlab/master/docker-compose.yml***Generate random strings that are at least 64 characters long for each of GITLAB_SECRETS_OTP_KEY_BASE, GITLAB_SECRETS_DB_KEY_BASE, and GITLAB_SECRETS_SECRET_KEY_BASE. These values are used for the following:GITLAB_SECRETS_OTP_KEY_BASE is used to encrypt 2FA secrets in the database. If you lose or rotate this secret, none of your users will be able to log in using 2FA.GITLAB_SECRETS_DB_KEY_BASE is used to encrypt CI secret variables, as well as import credentials, in the database. If you lose or rotate this secret, you will not be able to use existing CI secrets.GITLAB_SECRETS_SECRET_KEY_BASE is used for password reset links, and other 'standard' auth features. If you lose or rotate this secret, password reset tokens in emails will reset.Tip: You can generate a random string using pwgen -Bsv1 64 and assign it as the value of GITLAB_SECRETS_DB_KEY_BASE.Start GitLab using:**docker-compose up**Alternatively, you can manually launch the gitlab container and the supporting postgresql and redis containers by following this three step guide.Step 1. Launch a postgresql containerdocker run --name gitlab-postgresql -d \    --env 'DB_NAME=gitlabhq_production' \    --env 'DB_USER=gitlab' --env 'DB_PASS=password' \    --env 'DB_EXTENSION=pg_trgm' \    --volume /srv/docker/gitlab/postgresql:/var/lib/postgresql \    sameersbn/postgresql:9.6-2Step 2. Launch a redis containerdocker run --name gitlab-redis -d \    --volume /srv/docker/gitlab/redis:/var/lib/redis \    sameersbn/redis:latestStep 3. Launch the gitlab containerdocker run --name gitlab -d \    --link gitlab-postgresql:postgresql --link gitlab-redis:redisio \    --publish 10022:22 --publish 10080:80 \    --env 'GITLAB_PORT=10080' --env 'GITLAB_SSH_PORT=10022' \    --env 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \    --env 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \    --env 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \    --volume /srv/docker/gitlab/gitlab:/home/git/data \    sameersbn/gitlab:9.5.2Please refer to Available Configuration Parameters to understand GITLAB_PORT and other configuration optionsNOTE: Please allow a couple of minutes for the GitLab application to start.Point your browser to http://localhost:10080 and set a password for the root user account.You should now have the GitLab application up and ready for testing. If you want to use this image in production then please read on.The rest of the document will use the docker command line. You can quite simply adapt your configuration into a docker-compose.yml file if you wish to do so.

0x06:参考
https://github.com/sameersbn/docker-gitlab/blob/master/README.md#installation

https://github.com/moby/moby/issues/16059

https://stackoverflow.com/questions/29727171/docker-compose-up-leads-to-client-and-server-dont-have-same-version-client