目次

概要

Gitlab の Container Registry でプライベートな Dockerレジストリを構築する。
※尚、ここでいう Gitlab はストレージサービスとしてのそれではなく、OSS としての Gitlab を指す。

GitLabのインストール

Gitlab を Docker コンテナとしてインストールする。
公開されているものは 1コンテナに必要なものが収まっている為、docker run でも良いのだが、コード化はしておきたいので docker-compose で構築する。

docker-compose.yml の作成

コンテナレジストリを有効にするには 環境変数: GITLAB_OMNIBUS_CONFIG に、幾つかのオプションを指定する必要がある。
具体的には、以下のようなものがあげられる。

オプション説明
xxxxxx
xxxxxx

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つだけ。

オプション設定例
registry_external_urlregistry_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

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'

コンテナ作成/起動

docker-compose up -d

netstat インストール

apt-get update
apt install net-tools

#####

https://docs.docker.com/registry/deploying/

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/


トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS