离线安装docker

背景描述

项目需要在研发环境虚拟机上安装docker部署应用。

所在的服务器是一个内网,无法访问到外网环境。

服务器OS版本是 麒麟V10 linux

安装docker

安装包下载

获取所需版本的docker binary包,官方链接https://download.docker.com/linux/static/stable/x86_64/.

我下载的是docker-26.1.4.tgz版本

解压压缩包,并把文件放在/usr/bin/

复制代码
tar -zxvf docker-26.1.4.tgz 
sudo cp docker/* /usr/bin/

新增用户组 docker。其他用户需要有docker的执行权限,只需将用户加入docker用户组即可

复制代码
$ sudo groupadd docker
$ sudo usermod -aG docker $USER

编写docker.service文件,放到目录/etc/systemd/system

复制代码
[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
ExecStart=/usr/bin/dockerd
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

启动docker service,并设置开机自启动

复制代码
$ sudo chmod +x /etc/systemd/system/docker.service
$ sudo systemctl daemon-reload
$ sudo systemctl start docker
$ sudo systemctl enable docker

验证

复制代码
 sudo systemctl status docker

使用docker ps命令报错

复制代码
[appadmin@iomapp ~]$ docker ps
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.45/containers/json": dial unix /var/run/docker.sock: connect: permission denied

检查是否将用户加入docker用户组,并且需要重新登录用户才能生效。

保存镜像进行打包,在另一台服务上使用

复制代码
docker save -o nginx_latestx86.tar  nginx:lastest

在另一台服务器上,docker加载tar包

复制代码
docker load -i nginx_latestx86.tar

测试启动nginx镜像,但是启动后访问nginx无反应参考

Docker:解决宿主机无法访问docker容器中nginx服务-CSDN博客

相关推荐
java_logo1 小时前
Apache Doris Docker 部署指南:实时分析数据库实战
数据库·docker·apache·doris·apache doris·轩辕镜像·docker部署doris
码农学院1 小时前
基于运维监控体系的网络品牌推广方案:从架构设计到技术实现
运维·网络
大耳朵-小飞象10 小时前
电力安全运维的智能密码:BACS如何破解设备全生命周期管理难题,让电网安全“看得见、管得住”?
运维·安全·智慧城市·能耗系统·楼宇智控·未来生活
极客侃科技11 小时前
制造企业 MES/APS 选型:SAP PP/DS 集成、ERP-MES 边界划分与一体化架构要点
运维·架构·制造
生活爱好者!14 小时前
我把NAS当作下载机,docker一键部署qb
运维·docker·容器
java_logo14 小时前
Docker Compose 部署 ClickHouse:快速搭建高性能列式数据库
数据库·clickhouse·docker·列式数据库·轩辕镜像·高性能数据库·clickhouse部署教程
MC皮蛋侠客15 小时前
uv 系列(七):CI/CD、Docker 与私有索引——生产级交付
python·ci/cd·docker·uv
尽兴-15 小时前
企业业务系统架构选型与渐进式演进
运维·系统架构·devops
Hui Baby15 小时前
K8S使用CRD和控制器简单应用
云原生·容器·kubernetes
通信小小昕16 小时前
Ubuntu 26.04 中文输入法安装
linux·运维·ubuntu