docker及docker-compose離線安裝

ubuntu離線安裝

tar -zxvf docker-26.1.3.tgz
  • 將解壓縮后的目錄,全部拷貝到 /usr/bin目錄下(特別提醒,不能將壓縮包,拷貝到 /usr/bin 目錄下再解壓,會不生效)
cp -p docker/* /usr/bin
# 遇到提示,全部overwrite即可,如下圖
image.png
  • 將docker注冊為系統(tǒng)服務(wù)
    1. 將docker.service文件放到 /usr/lib/systemd/system/ 目錄下
    2. 將docker.socket文件放到 /usr/lib/systemd/system/ 目錄下
      可以從在線安裝docker的目錄下,拷貝這兩個文件,可以直接使用,簡書插入不了附件,以下是這兩個文件的內(nèi)容
      docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service containerd.service time-set.target
Wants=network-online.target containerd.service
Requires=docker.socket

[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
#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutStartSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity

# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity

# 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
OOMScoreAdjust=-500

[Install]
WantedBy=multi-user.target

docker.socket

[Unit]
Description=Docker Socket for the API

[Socket]
# If /var/run is not implemented as a symlink to /run, you may need to
# specify ListenStream=/var/run/docker.sock instead.
ListenStream=/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker

[Install]
WantedBy=sockets.target
  • 給系統(tǒng)增加一個docker組
groupadd docker
  • 重啟守護(hù)進(jìn)程
systemctl daemon-reload
  • 啟動docker
systemctl start docker
  • 設(shè)置docker開啟啟動
systemctl enable docker
  • 安裝docker-compose
  1. https://github.com/docker/compose/releases 下載linux環(huán)境包 docker-compose-Linux-x86_64
    image.png
  2. 將下載的文件,拷貝到目標(biāo)機(jī)器的 /usr/local/bin/ 目錄下,將docker-compose-Linux-x86_64文件重命名為 docker-compse
  3. 給 docker-compose 文件授權(quán) chmod +x /usr/local/bin/docker-compose
  4. 測試 docker-compse -v 即可以查看對應(yīng)版本信息

centos離線安裝

arm64離線安裝(步驟與ubuntu一致,有幾個點(diǎn)需要注意)

  1. docker.service 內(nèi)容用以下的
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target
  1. 裝好之后,pull鏡像的時候如果出現(xiàn)報錯:
    Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: container_linux.go:318: starting container process caused "permission denied": unknown

解決方法:執(zhí)行命令 yum remove podman

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容