1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Dockerを使ってGitLabを導入する(for Ubuntu 22.04)

Posted at

インストール(Ubuntu 22.04)

公式とは違いバージョンにこだわりがなければUbuntuの公式リポジトリにあるものを使用する。

sudo apt install docker.io docker-compose-v2

※docker-compose(version1)もあるがversion2もあるのでそっちを入れた。

プロキシがある場合

dockerデーモンを使ってダウンロードが行われるので、systemdの実行時に環境変数でプロキシが設定されている必要がある。

以下を記入

/etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://[user:pass@]host[:port]"
Environment="HTTPS_PROXY=http://[user:pass@]host[:port]"

※user,passに記号があってパーセントエンコードする場合で%を記入する場合は注意必要。エスケープ文字として認識されてしまうため%%と2重で記入すること。

systemdの再起動

sudo systemctl daemon-reload
sudo systemctl restart docker

設定

dockerグループに自身を追加

sudo usermod -aG docker $USER

※しなくてもsudoコマンドで可能だが、dockerグループに入るとsudoなしでも管理者権限相当のことができる。

/srv/gitlabを追加(データを格納する場所。適宜好きな場所に指定。)

sudo mkdir -p /srv/gitlab
cd /srv
sudo chown $USER:docker gitlab

docker-composeを使う

設定ファイルをユーザーのディレクトリに格納する。

mkdir ~/gitlab_web
cd ~/gitlab_web
> docker-compose.yml
docker-compose.yml
version: '3.6'
services:
  gitlab:
    image: 'gitlab/gitlab-ee:latest'
    restart: always
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://gitlab.example.com:8080'
        gitlab_rails['gitlab_shell_ssh_port'] = 2222
        nginx['listen_port'] = 80
    ports:
      - '8080:80'
      - '2222:22'
    volumes:
      - '/srv/gitlab/config:/etc/gitlab'
      - '/srv/gitlab/logs:/var/log/gitlab'
      - '/srv/gitlab/data:/var/opt/gitlab'
    shm_size: '256m'

gitlab.example.comは自身のドメインやIPアドレス。
httpのポートを開ける、その時のポートを8080にする。
sshのポートを開ける、その時のポートを2222にする。
これでsshやhttpプロトコルで接続可能。

httpサーバやssh接続しないとかなら80,22そのままつかってもよい。8080,2222を80,22に変える。

実行

cd ~/gitlab_web
docker compose up -d

しばらくして

docker ps

を実行してSTATUSがhealthyになるまで待つ。

CONTAINER ID   IMAGE                     COMMAND             CREATED             STATUS                       PORTS
              NAMES
0e8b680dba4e   gitlab/gitlab-ee:latest   "/assets/wrapper"   About an hour ago   Up About an hour (healthy)   443/tcp, 0.0.0.0:2222->22/tcp, :::2222->22/tcp, 0.0.0.0:8080->80/tcp, :::8080->80/tcp   gitlab_web-gitlab-1

rootパスワードを見る

1時間以内に消えるのでこれをメモしてログインをする。その後パスワードを覚えやすいものに変える。

# "-it"の後はコンテナの名前
docker exec -it gitlab_web-gitlab-1 grep 'Password:' /etc/gitlab/initial_root_password

Webブラウザで入る

おわり。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?