新しくインストールされた Debain はソースを変更する必要があります
- /etc/apt/sources.list ファイルを編集します
nano /etc/apt/sources.list
- テキスト内のすべてのソースに注目し、以下のソースをコピーして貼り付けてください。プロテストは効果的です。
deb https://mirrors.huaweicloud.com/debian/ bullseye main non-free contrib
deb https://mirrors.huaweicloud.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.huaweicloud.com/debian/ bullseye-backports main non-free contrib
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bullseye-security main non-free contrib
deb https://security.debian.org/debian-security bullseye-security main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian/ bullseye-updates main contrib
deb-src https://mirrors.huaweicloud.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bullseye-security main non-free contrib
deb-src https://security.debian.org/debian-security bullseye-security main non-free contrib
-
を押して入力
ctrl+x
し、Y
を押して回车
保存します -
ソースを更新するには、次のコマンドを入力します。
apt update
-
必要なパッケージをインストールします。
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
- Docker GPG キーを追加する
システムが Docker パッケージを信頼できるように、Docker GPG キーを追加します。
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- Dockerパッケージソースを追加する
Docker パッケージ ソースをシステムの APT ソース リストに追加します。
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- Docker エンジンをインストールする
次のコマンドを使用して、最新バージョンの Docker Engine とその他の必要なパッケージをインストールします。
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
- ドッカーを起動します
次のコマンドで Docker を起動します。
sudo systemctl start docker
Docker が実行されているかどうかを確認します。
sudo systemctl status docker
- Docker を使用する
インストールが完了したら、「docker」コマンドを使用してターミナル上で Docker を使用できるようになります。たとえば、次のコマンドを実行して Docker のバージョン情報を表示します。
docker version
あるいは、次のコマンドを実行してコンテナを起動することもできます。
docker run hello-world
これにより、「hello-world」イメージがダウンロードされ、コンテナーで実行されます。すべてが正しく設定されている場合、対応する出力が端末に表示されます。
これが Debian 11 に Docker をインストールするのに役立つことを願っています。