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をやってみる①

Posted at

はじめに

仕事でコンテナに関わることになった。
手始めにDockerを用いて、GitLabを立ててみる

まずは、下記を参考にやってみる

前提条件
 Virtualbox 7.1.4 上に Rocky Linux9.6をインストール

Dokcer環境構築

① パッケージのアップデート
[root@git-server ~]# dnf update -y
Rocky Linux 9 - BaseOS                                                5.5 kB/s | 4.1 kB     00:00
Rocky Linux 9 - BaseOS                                                2.1 MB/s | 2.5 MB     00:01
Rocky Linux 9 - AppStream                                             6.2 kB/s | 4.5 kB     00:00
Rocky Linux 9 - Extras                                                3.5 kB/s | 2.9 kB     00:00
依存関係が解決しました。
======================================================================================================
 パッケージ                 Arch         バージョン                             リポジトリー    サイズ
======================================================================================================
インストール:
 kernel                     x86_64       5.14.0-570.21.1.el9_6                  baseos          1.8 M
アップグレード:
 dracut                     x86_64       057-88.git20250311.el9_6               baseos          385 k
 dracut-config-rescue       x86_64       057-88.git20250311.el9_6               baseos           12 k
 dracut-network             x86_64       057-88.git20250311.el9_6               baseos           68 k
 dracut-squash              x86_64       057-88.git20250311.el9_6               baseos           12 k
 firefox                    x86_64       128.11.0-1.el9_6                       appstream       126 M

 ~~ 中略 ~~

トランザクションの概要
======================================================================================================
インストール     4 パッケージ
アップグレード  14 パッケージ

ダウンロードサイズの合計: 244 M

  ~~ 省略 ~~

RHEL9からDokcerエンジンとdockerコマンドが削除され、
代わりにPodmanを使用してコンテナを実行することが推奨されているらしい。

② podmanパッケージのインストール
[root@git-server ~]# dnf -y install podman
メタデータの期限切れの最終確認: 0:13:00 前の 2025年06月23日 16時50分14秒 に実施しました。
パッケージ podman-5:5.4.0-9.el9_6.x86_64 は既にインストールされています。
依存関係が解決しました。
行うべきことはありません。
完了しました!

インストールが完了したら、バージョンを確認してみる。

③ podmanのバージョン確認
[root@git-server ~]# dnf -y install podman
メタデータの期限切れの最終確認: 0:13:00 前の 2025年06月23日 16時50分14秒 に実施しました。
パッケージ podman-5:5.4.0-9.el9_6.x86_64 は既にインストールされています。
依存関係が解決しました。
行うべきことはありません。
完了しました!

dockerコマンドが実行できるようにコマンドをインストールする。

④ dockerコマンドのインストール
[root@git-server ~]# dnf -y install podman-docker
メタデータの期限切れの最終確認: 0:13:59 前の 2025年06月23日 16時50分14秒 に実施しました。
依存関係が解決しました。
======================================================================================================
 パッケージ                アーキテクチャー   バージョン                  リポジトリー          サイズ
======================================================================================================
インストール:
 podman-docker             noarch             5:5.4.0-9.el9_6             appstream              57 k

トランザクションの概要
======================================================================================================
インストール  1 パッケージ

 ~~ 中略 ~~

インストール済み:
  podman-docker-5:5.4.0-9.el9_6.noarch

完了しました!

同じように、ここでもバージョンを確認する。

⑤ バージョン確認
[root@git-server ~]# docker -v
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
podman version 5.4.0

インストールできたので、コンテナの一覧を確認。
動いているコンテナが存在しないことが確認できる。

⑥ 現在実行中のDockerコンテナの一覧を表示
[root@git-server ~]# docker ps -a
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
CONTAINER ID  IMAGE       COMMAND     CREATED     STATUS      PORTS       NAMES

バージョン確認時に出力される Emulate Docker ~ quiet msg. の抑止。

⑦ メッセージの抑止
[root@git-server ~]# docker -v
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
podman version 5.4.0
[root@git-server ~]# touch /etc/containers/nodocker
[root@git-server ~]# docker -v
podman version 5.4.0

動作確認のために、コンテナイメージを取得。

⑧ hello-worldコンテナの取得
[root@git-server ~]# docker pull hello-world
Resolved "hello-world" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull quay.io/podman/hello:latest...
Getting image source signatures
Copying blob 81df7ff16254 done   |
Copying config 5dd467fce5 done   |
Writing manifest to image destination
5dd467fce50b56951185da365b5feee75409968cbab5767b9b59e325fb2ecbc0

取得したイメージを確認する。

⑨ 取得したイメージの確認
[root@git-server ~]# docker images
REPOSITORY            TAG         IMAGE ID      CREATED        SIZE
quay.io/podman/hello  latest      5dd467fce50b  13 months ago  787 kB

コンテナの実行。

⑩ コンテナ実行
[root@git-server ~]# docker run 5dd467fce50b
!... Hello Podman World ...!

         .--"--.
       / -     - \
      / (O)   (O) \
   ~~~| -=(,Y,)=- |
    .---. /`  \   |~~
 ~/  o  o \~~~~.----. ~~
  | =(X)= |~  / (O (O) \
   ~~~~~~~  ~| =(Y_)=-  |
  ~~~~    ~~~|   U      |~~

Project:   https://github.com/containers/podman
Website:   https://podman.io
Desktop:   https://podman-desktop.io
Documents: https://docs.podman.io
YouTube:   https://youtube.com/@Podman
X/Twitter: @Podman_io
Mastodon:  @Podman_io@fosstodon.org

再度、コンテナの一覧を確認。

⑪ コンテナ一覧の確認
[root@git-server ~]# docker ps -a
CONTAINER ID  IMAGE                        COMMAND               CREATED        STATUS                    PORTS       NAMES
fa92572c3cb5  quay.io/podman/hello:latest  /usr/local/bin/po...  5 minutes ago  Exited (0) 5 minutes ago              ecstatic_gagarin

実行したので、削除する。

⑫ コンテナ一覧の確認
[root@git-server ~]# docker ps -a
CONTAINER ID  IMAGE                        COMMAND               CREATED         STATUS                     PORTS       NAMES
fa92572c3cb5  quay.io/podman/hello:latest  /usr/local/bin/po...  9 minutes ago   Exited (0) 9 minutes ago               ecstatic_gagarin
e2cf920d978e  quay.io/podman/hello:latest  /usr/local/bin/po...  56 seconds ago  Exited (0) 55 seconds ago              practical_keldysh
[root@git-server ~]#
[root@git-server ~]# docker rm e2cf920d978e
e2cf920d978e
[root@git-server ~]#
[root@git-server ~]# docker ps -a
CONTAINER ID  IMAGE                        COMMAND               CREATED        STATUS                    PORTS       NAMES
fa92572c3cb5  quay.io/podman/hello:latest  /usr/local/bin/po...  9 minutes ago  Exited (0) 9 minutes ago              ecstatic_gagarin
[root@git-server ~]#
[root@git-server ~]# docker rm fa92572c3cb5
fa92572c3cb5
[root@git-server ~]#
[root@git-server ~]# docker ps -a
CONTAINER ID  IMAGE       COMMAND     CREATED     STATUS      PORTS       NAMES
[root@git-server ~]#

ゴミが残らないように、イメージも削除する。

⑫ イメージの削除
[root@git-server ~]# docker images
REPOSITORY            TAG         IMAGE ID      CREATED        SIZE
quay.io/podman/hello  latest      5dd467fce50b  13 months ago  787 kB
[root@git-server ~]#
[root@git-server ~]# docker rmi 5dd467fce50b
Untagged: quay.io/podman/hello:latest
Deleted: 5dd467fce50b56951185da365b5feee75409968cbab5767b9b59e325fb2ecbc0
[root@git-server ~]#
[root@git-server ~]# docker images
REPOSITORY  TAG         IMAGE ID    CREATED     SIZE
[root@git-server ~]#

その他
docker run の際に、-it;input tty を付与して起動することで、コンテナにログインした状態で起動できる

[root@git-server ~]# docker run -it ubuntu bash
Resolved "ubuntu" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull docker.io/library/ubuntu:latest...
Getting image source signatures
Copying blob d9d352c11bbd done   |
Copying config bf16bdcff9 done   |
Writing manifest to image destination
root@5137dc873afa:/#
root@5137dc873afa:/#
root@5137dc873afa:/# pwd
/
root@5137dc873afa:/# ls -ltr ./
total 0
lrwxrwxrwx.   1 root root   8 Apr 22  2024 sbin -> usr/sbin
lrwxrwxrwx.   1 root root   9 Apr 22  2024 lib64 -> usr/lib64
lrwxrwxrwx.   1 root root   7 Apr 22  2024 lib -> usr/lib
drwxr-xr-x.   2 root root   6 Apr 22  2024 boot
lrwxrwxrwx.   1 root root   7 Apr 22  2024 bin -> usr/bin
drwxr-xr-x.  12 root root 133 May 29 02:14 usr
drwxr-xr-x.   2 root root   6 May 29 02:14 srv
drwxr-xr-x.   2 root root   6 May 29 02:14 opt
drwxr-xr-x.   2 root root   6 May 29 02:14 mnt
drwxr-xr-x.   2 root root   6 May 29 02:14 media
drwxr-xr-x.  11 root root 139 May 29 02:22 var
drwx------.   2 root root  37 May 29 02:22 root
drwxrwxrwt.   2 root root   6 May 29 02:22 tmp
drwxr-xr-x.   3 root root  20 May 29 02:23 home
dr-xr-xr-x.  13 root root   0 Jun 29 00:31 sys
drwxr-xr-x.   1 root root  18 Jun 29 00:40 etc
dr-xr-xr-x. 245 root root   0 Jun 29 00:40 proc
drwxr-xr-x.   1 root root  42 Jun 29 00:40 run
drwxr-xr-x.   5 root root 360 Jun 29 00:40 dev
root@5137dc873afa:/#
root@5137dc873afa:/# exit
exit  <---- ここでコンテナを抜ける + 終了させる(抜けるだけなら ctrl + p + q)
[root@git-server ~]#

以上.

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?