Debain11のソース変更とdockerのインストール方法

新しくインストールされた Debain はソースを変更する必要があります

  1. /etc/apt/sources.list ファイルを編集します
nano /etc/apt/sources.list
  1. テキスト内のすべてのソースに注目し、以下のソースをコピーして貼り付けてください。プロテストは効果的です。
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

ここに画像の説明を挿入

  1. を押して入力ctrl+xし、Yを押して回车保存します

  2. ソースを更新するには、次のコマンドを入力します。apt update

  3. 必要なパッケージをインストールします。

sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
  1. 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
  1. 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
  1. Docker エンジンをインストールする

次のコマンドを使用して、最新バージョンの Docker Engine とその他の必要なパッケージをインストールします。

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
  1. ドッカーを起動します

次のコマンドで Docker を起動します。

sudo systemctl start docker

Docker が実行されているかどうかを確認します。

sudo systemctl status docker
  1. Docker を使用する

インストールが完了したら、「docker」コマンドを使用してターミナル上で Docker を使用できるようになります。たとえば、次のコマンドを実行して Docker のバージョン情報を表示します。

docker version

あるいは、次のコマンドを実行してコンテナを起動することもできます。

docker run hello-world

これにより、「hello-world」イメージがダウンロードされ、コンテナーで実行されます。すべてが正しく設定されている場合、対応する出力が端末に表示されます。

これが Debian 11 に Docker をインストールするのに役立つことを願っています。

おすすめ

転載: blog.csdn.net/the_liang/article/details/129777642