0
0

【Docker】軽量版Ubuntuイメージをunminimizeで通常に戻す

Last updated at Posted at 2024-10-03

はじめに

シェルの勉強をしようと思って、Ubuntuイメージでコンテナ起動したときに、一部コマンドが使えなかったので調べて使えるようにした際の備忘録です。

エラーメッセージちゃんと読みましょうという結論でした。

環境構築

dockerイメージをダウンロードする

docker pull ubuntu:20.04

イメージの確認

docker images

REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
ubuntu       20.04     9522b5ff29b8   2 weeks ago   72.8MB

コンテナに入って、シェル起動

docker run -it --name ubuntu-test 9522b5ff29b8

使えないコマンド発覚

公式のUbuntuイメージは軽量化されているようです。
unminimizeコマンドで復元できるらしい。
AlpineやBusyboxなんかは軽量化されていて必要最小限なのは知っていたけど、Ubuntuも軽量化されているんだね。

root@9af84acf4d00:/# man ls
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.

To restore this content, including manpages, you can run the 'unminimize'
command. You will still need to ensure the 'man-db' package is installed.

# DeepL翻訳
このシステムは、ユーザーがログインしないシステム上で不要なパッケージやコンテンツを削除することで最小化されています。

manページを含むこのコンテンツを復元するには、「unminimize」コマンドを実行します。
ただし、「man-db」パッケージがインストールされていることを確認する必要があります。

unminimize コマンドを実行してみる

root@9af84acf4d00:/# unminimize
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.

This script restores content and packages that are found on a default
Ubuntu server system in order to make this system more suitable for
interactive use.

Reinstallation of packages may fail due to changes to the system
configuration, the presence of third-party packages, or for other
reasons.

This operation may take some time.

Would you like to continue? [y/N] y


# DeepL翻訳
このシステムは、ユーザーがログインしないシステムで必要のないパッケージやコンテンツを削除することで最小化されています。

このスクリプトは、Ubuntuサーバーシステムのデフォルトでインストールされているコンテンツとパッケージを復元し、
このシステムを対話的な使用に適したものにします。

パッケージの再インストールは、システム構成の変更、サードパーティパッケージの存在、その他の理由により失敗する可能性があります。

この操作には時間がかかる場合があります。

続行しますか? [y/N] y

再確認

root@9af84acf4d00:/# man ls
bash: /usr/bin/man: No such file or directory

使えなかったので、man-db パッケージをインストールしてみる

root@9af84acf4d00:/# apt install man-db
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  bsdmainutils groff-base libbsd0 libgdbm6 libpipeline1 libuchardet0
Suggested packages:
  cpp wamerican | wordlist whois vacation groff gdbm-l10n apparmor less www-browser
The following NEW packages will be installed:
  bsdmainutils groff-base libbsd0 libgdbm6 libpipeline1 libuchardet0 man-db
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 2306 kB of archives.
After this operation, 7775 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y

再々確認

使えるようになった!

root@9af84acf4d00:/# man ls
LS(1)                                                                User Commands                                                               LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List information about the FILEs (the current directory by default).  Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

       Mandatory arguments to long options are mandatory for short options too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..

参考

0
0
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
0
0