Centos离线安装Docker(无坑版)

1、下载并上传docker离线安装包

官方地址:安装包下载

2、上传到离线安装的服务器解压

tar -zxvf docker-28.1.1.tgz

#拷贝解压二进制文件到相关目录
cp docker/* /usr/bin/

3、创建docker启动文件

cat << EOF > /usr/lib/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
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutStartSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
KillMode=process
OOMScoreAdjust=-500

[Install]
WantedBy=multi-user.target

EOF

4、创建Containerd启停文件

cat << EOF > /usr/lib/systemd/system/containerd.service 

# Copyright The containerd Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target

[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd

Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5

# 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 supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999

[Install]
WantedBy=multi-user.target

EOF

5、启动Containerd

systemctl enable --now containerd

systemctl status containerd

6、启动docker

systemctl enable --now docker

systemctl status docker

二、镜像包处理

1、从有镜像包的服务器导出镜像

docker save -o oracle-12c.zip 21789d4d876f

2、上传导出的镜像到离线服务器上

docker load < oracle-12c.zip

有了镜像后,就可以正常创建服务了。

参考地址:CentOS7.9安装

### CentOS 离线环境下 DockerDocker-Compose 安装 #### 准备工作 为了在离线环境中成功安装 Docker 及其组件,需提前在线获取所需文件并传输至目标机器。 #### 获取 Docker 文件包 从一台联网计算机下载适用于 CentOSDocker RPM 包以及对应的依赖项。可以访问官方仓库或镜像站点来获得最新本的软件包集合。对于特定本的需求,则应指定确切的 URL 地址以确保兼容性[^1]。 #### 复制 Docker 命令到系统路径 将事先准备好的 Docker 二进制文件复制到系统的可执行目录 `/usr/bin` 下面,以便全局调用该工具: ```bash cp docker/* /usr/bin/ ``` #### 设置 Docker 自启动和服务状态管理 通过 `systemctl` 工具配置 Docker 服务开机自动运行,并立即激活此服务: ```bash systemctl enable docker systemctl start docker ``` #### 获取 Docker Compose 文件 同样地,在有网络连接的地方预先下载好适合当前操作系统的 Docker Compose 本(例如 Linux x86_64 架构),并将之重命名为方便使用的名称放置于 `/usr/local/bin/` 路径下: ```bash mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose ``` 或者按照具体发布的链接地址直接拉取对应平台架构下的稳定发布件: ```bash curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose ``` #### 授权给定脚本执行权限 赋予上述两个程序必要的读写许可权,使其能够正常运作: ```bash chmod +x /usr/local/bin/docker-compose ``` 完成以上步骤之后,便可以在无互联网接入的情况下正常使用 DockerDocker Compose 来构建容器化应用环境了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值