linux离线安装docker与compose

简介: linux离线安装docker与compose

前言

官方提供免安装的二进制程序包,解压后就能用。

PS1: docker基于iptables做路由转发,所以亲测debian11上需要先安装iptables(apt install -y iptables)

docker安装步骤

  1. 官网下载安装包。
  2. 解压安装包,将安装包内的二进制程序解压到/usr/local/bin目录。
  3. 建立docker的数据存放目录:
mkdir -p /home/data/docker
  1. 创建docker的service文件(/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
# 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/local/bin/dockerd --data-root /home/data/docker
 
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
  1. 使配置生效
systemctl daemon-reload
systemctl start docker
systemctl enable docker
  1. 验证
docker info

docker-compose安装步骤

  1. 官网下载二进制程序包
  2. 重命名为docker-compose,并移到/usr/local/bin
  3. 验证
docker-compose --version

配置docker的daemon.json

  • vim /etc/docker/daemon.json(检查格式:cat /etc/docker/daemon.json | python -m json.tool
{
    "exec-opts": [
        "native.cgroupdriver=systemd"
    ],
    "log-driver": "json-file",
    "log-level": "warn",
    "log-opts": {
        "max-size": "100m"
    },
    "storage-driver": "overlay2",
    "storage-opts": [
        "overlay2.override_kernel_check=true"
    ],
    "registry-mirrors": [
        "https://sral7lkb.mirror.aliyuncs.com"
    ],
    "ip-forward": true,
    "ip-masq": false,
    "iptables": false,
    "ipv6": false,
    "live-restore": true,
    "selinux-enabled": false,
    "bip": "172.17.200.1/24",
    "data-root": "/home/data/docker"
}

官方完全示例

{
  "allow-nondistributable-artifacts": [],
  "api-cors-header": "",
  "authorization-plugins": [],
  "bip": "",
  "bridge": "",
  "cgroup-parent": "",
  "containerd": "/run/containerd/containerd.sock",
  "containerd-namespace": "docker",
  "containerd-plugin-namespace": "docker-plugins",
  "data-root": "",
  "debug": true,
  "default-address-pools": [
    {
      "base": "172.30.0.0/16",
      "size": 24
    },
    {
      "base": "172.31.0.0/16",
      "size": 24
    }
  ],
  "default-cgroupns-mode": "private",
  "default-gateway": "",
  "default-gateway-v6": "",
  "default-runtime": "runc",
  "default-shm-size": "64M",
  "default-ulimits": {
    "nofile": {
      "Hard": 64000,
      "Name": "nofile",
      "Soft": 64000
    }
  },
  "dns": [],
  "dns-opts": [],
  "dns-search": [],
  "exec-opts": [],
  "exec-root": "",
  "experimental": false,
  "features": {},
  "fixed-cidr": "",
  "fixed-cidr-v6": "",
  "group": "",
  "hosts": [],
  "proxies": {
    "http-proxy": "http://proxy.example.com:80",
    "https-proxy": "https://proxy.example.com:443",
    "no-proxy": "*.test.example.com,.example.org",
  },
  "icc": false,
  "init": false,
  "init-path": "/usr/libexec/docker-init",
  "insecure-registries": [],
  "ip": "0.0.0.0",
  "ip-forward": false,
  "ip-masq": false,
  "iptables": false,
  "ip6tables": false,
  "ipv6": false,
  "labels": [],
  "live-restore": true,
  "log-driver": "json-file",
  "log-level": "",
  "log-opts": {
    "cache-disabled": "false",
    "cache-max-file": "5",
    "cache-max-size": "20m",
    "cache-compress": "true",
    "env": "os,customer",
    "labels": "somelabel",
    "max-file": "5",
    "max-size": "10m"
  },
  "max-concurrent-downloads": 3,
  "max-concurrent-uploads": 5,
  "max-download-attempts": 5,
  "mtu": 0,
  "no-new-privileges": false,
  "node-generic-resources": [
    "NVIDIA-GPU=UUID1",
    "NVIDIA-GPU=UUID2"
  ],
  "oom-score-adjust": 0,
  "pidfile": "",
  "raw-logs": false,
  "registry-mirrors": [],
  "runtimes": {
    "cc-runtime": {
      "path": "/usr/bin/cc-runtime"
    },
    "custom": {
      "path": "/usr/local/bin/my-runc-replacement",
      "runtimeArgs": [
        "--debug"
      ]
    }
  },
  "seccomp-profile": "",
  "selinux-enabled": false,
  "shutdown-timeout": 15,
  "storage-driver": "",
  "storage-opts": [],
  "swarm-default-advertise-addr": "",
  "tls": true,
  "tlscacert": "",
  "tlscert": "",
  "tlskey": "",
  "tlsverify": true,
  "userland-proxy": false,
  "userland-proxy-path": "/usr/libexec/docker-proxy",
  "userns-remap": ""
}

补充

  • 普通用户如需使用二进制方式安装的docker,可参考以下步骤。假设普通用户的用户名为admin
# 1. 创建docker用户组
groupadd docker
# 2. 将admin用户加到docker用户组
usermod admin -a -G docker
# 3. 重启docker
systemctl restart docker
# 4. admin用户执行docker命令进行测试

参考

相关文章
|
5月前
|
人工智能 前端开发 Docker
从本地到云端:用 Docker Compose 与 Offload 构建可扩展 AI 智能体
在 AI 智能体开发中,开发者常面临本地调试与云端部署的矛盾。本文介绍如何通过 Docker Compose 与 Docker Offload 解决这一难题,实现从本地快速迭代到云端高效扩容的全流程。内容涵盖多服务协同、容器化配置、GPU 支持及实战案例,助你构建高效、一致的 AI 智能体开发环境。
547 2
从本地到云端:用 Docker Compose 与 Offload 构建可扩展 AI 智能体
|
5月前
|
运维 数据可视化 开发者
2025年 三个 Docker Compose 可视化管理器测评
本文对比了三款主流的 Docker Compose 可视化管理工具。随着 Docker 的普及,Compose 已成为多容器应用部署的标准,但 YAML 配置复杂、协作困难等问题也日益突出。三款工具各有侧重:Docker Desktop 适合个人本地开发,Portainer 适合小团队运维管理,而 Websoft9 则通过 GitOps 实现了强大的版本控制与团队协作能力。文章从可视化编辑、部署便捷性、版本管理等方面进行评测,为不同使用场景提供了推荐方案,展望了未来 Compose 管理向 GitOps 深度融合的发展趋势。
746 1
2025年 三个 Docker Compose 可视化管理器测评
|
数据可视化 开发工具 git
GitOps 驱动的 Docker Compose 可视工具化来了,图形化编辑器上玩转容器编排
Docker Compose 简化了多容器应用的部署,但随着应用复杂度上升,文本配置方式逐渐暴露出维护难、协作效率低等问题。基于 GitOps 的可视化 Docker Compose 工具应运而生,通过图形界面降低使用门槛,提升配置准确性和团队协作效率。结合 GitOps,实现配置变更的版本追踪、自动化部署与环境一致性,为多容器应用管理提供高效、安全的解决方案。
|
7月前
|
NoSQL Redis Docker
使用Docker Compose工具进行容器编排的教程
以上就是使用Docker Compose进行容器编排的基础操作。这能帮你更有效地在本地或者在服务器上部署和管理多容器应用。
658 11
|
7月前
|
NoSQL 安全 Redis
Docker Compose :从入门到企业级部署
Docker Compose 是用于定义和运行多容器应用的工具,支持服务、网络和卷三大核心要素。通过简洁的 YAML 文件,可实现应用的快速部署与管理,适用于开发、测试及生产环境。
614 1
|
9月前
|
网络协议 Ubuntu Docker
Docker Compose--命令说明
Docker Compose--命令说明
1632 30
|
9月前
|
网络协议 NoSQL Redis
Docker Compose--模板文件
Docker Compose--模板文件
826 29
|
9月前
|
Linux Docker Windows
Docker Compose
Docker Compose
1140 29
|
8月前
|
Linux iOS开发 Docker
MyEMS开源系统安装之Linux/macOS上的DOcker
本指南详细介绍了如何在Linux/macOS上使用Docker部署MyEMS系统。主要内容包括:前置条件(如安装Docker、npm和MySQL),以及分步骤部署各个组件(如myems-api、myems-admin、myems-modbus-tcp等)。每个步骤涵盖源代码复制、环境配置、镜像构建、容器运行及日志管理等操作,并提供了多平台构建的支持。最后,指南还说明了默认端口和登录凭据,帮助用户快速启动并访问MyEMS的管理界面和Web界面。
275 1

热门文章

最新文章