#author("2020-01-17T12:26:16+00:00","","") #mynavi() #setlinebreak(on); * 目次 [#uc91c552] #contents - 関連 -- [[gitコマンド]] -- [[dockerメモ]] -- [[GitリポジトリをMavenリポジトリとして使用する]] - 参考 -- https://docs.gitlab.com/omnibus/docker/ -- https://docs.gitlab.com/ce/user/packages/container_registry/ -- https://docs.gitlab.com/omnibus/docker/#install-gitlab-using-docker-compose * 概要 [#l882ecb6] #html(<div>) Gitlab の Container Registry でプライベートな Dockerレジストリを構築する。 ※尚、ここでいう Gitlab はストレージサービスとしてのそれではなく、OSS としての Gitlab を指す。 #html(</div>) * GitLabのインストール [#n13046ab] #html(<div class="pl10">) Gitlab を Docker コンテナとしてインストールする。 公開されているものは 1コンテナに必要なものが収まっている為、docker run でも良いのだが、コード化はしておきたいので docker-compose で構築する。 ** docker-compose.yml の作成 [#e6cd9ec2] #html(<div class="pl10">) コンテナレジストリを有効にするには 環境変数: GITLAB_OMNIBUS_CONFIG に、幾つかのオプションを指定する必要がある。 具体的には、以下のようなものがあげられる。 | オプション | 説明 |h | xxx | xxx | | xxx | xxx | ※ https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template ただし、以下の記載によると、Omnibus GitLab(docker image 版のGitlab)を使用している場合、コンテナレジストリはデフォルトドメインのポート5050で自動的に有効になる模様。 https://docs.gitlab.com/ce/administration/packages/container_registry.html#enable-the-container-registry なので、最低限指定すべきオプションは以下の3つだけ。 | オプション | 設定例 |h | registry_external_url | registry_external_url 'https://gitlab.example.com:4567' | | registry_nginx['ssl_certificate'] | registry_nginx['ssl_certificate'] = "/path/to/certificate.pem" | | registry_nginx['ssl_certificate_key'] | registry_nginx['ssl_certificate_key'] = "/path/to/certificate.key" | ※ https://docs.gitlab.com/ce/administration/packages/container_registry.html#configure-container-registry-under-an-existing-gitlab-domain docker-compose.yml #mycode2(){{ web: image: 'gitlab/gitlab-ce:latest' restart: always hostname: 'gitlab.example.com' container_name: gitlab hostname: localhost environment: GITLAB_OMNIBUS_CONFIG: | external_url "http://localhost" gitlab_rails['gitlab_shell_ssh_port'] = 2224 ports: - '80:80' - '443:443' - '22:22' volumes: - './gitlab/config:/etc/gitlab' - './gitlab/logs:/var/log/gitlab' - './gitlab/data:/var/opt/gitlab' }} #html(</div>) ** コンテナ作成/起動 [#c87a7e09] #html(<div class="pl10">) #myterm2(){{ docker-compose up -d }} #html(</div>) #html(</div>) * netstat インストール [#p3f4542c] apt-get update apt install net-tools ##### https://docs.docker.com/registry/deploying/ #mycode2(){{ docker run -d \ --restart=always \ --name registry \ -v "$(pwd)"/certs:/certs \ -e REGISTRY_HTTP_ADDR=0.0.0.0:443 \ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \ -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \ -p 443:443 \ registry:2 }} https://docs.docker.com/registry/deploying/