Docker サービスのオフライン インストール

 实际项目部署中经常会有服务器没有外网权限的情况,针对没有外网情况下如何安装docker服务

1. docker公式オフラインパッケージをダウンロードする

外部ネットワークがある環境では、まずオフラインパッケージをダウンロードしてください (
インストールパッケージの正式アドレス: https://download.docker.com/linux/static/stable/x86_64/)
ここに画像の説明を挿入

2. オフライン パッケージをサーバーにアップロードします

scp コマンドまたは ftp ツールを使用して、ダウンロードしたオフライン パッケージを指定したサーバーにアップロードします

3. オフラインでのパッケージ解凍

tar -zxvf docker-20.10.8.tgz
ここに画像の説明を挿入

4. ファイルを /usr/bin/ にコピーして解凍します。

sudo cp docker/* /usr/bin/
ここに画像の説明を挿入

5. dockerをサービスとして登録する

新しい docker.service ファイルを /etc/systemd/system/ ディレクトリに追加します。
sudo vi /etc/systemd/system/docker.service
入力内容

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
  
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
# 如果有搭建私有镜像仓库,--insecure-registry设置为私有镜像仓库地址。
ExecStart=/usr/bin/dockerd --selinux-enabled=false --insecure-registry=127.0.0.1
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
  
[Install]
WantedBy=multi-user.target

6. Dockerサービスを開始する

docker.serviceに実行権限を与える
chmod +x /etc/systemd/system/docker.service
ここに画像の説明を挿入

設定ファイルをリロードして有効にします。
systemctl daemon-reload
ここに画像の説明を挿入


sudo systemctlを起動docker を起動
ここに画像の説明を挿入

起動後にサービスが自動的に開始されるように設定します。
sudo systemctl enable docker.service
ここに画像の説明を挿入

サービス ステータスの表示
systemctl ステータス ドッカー
ここに画像の説明を挿入

おすすめ

転載: blog.csdn.net/weixin_44835704/article/details/121287297