离线安装 docker & docker-compose

离线安装 docker & docker-compose

安装包下载

docker下载

  • 点击上方链接进入到下载页面,选择需要部署服务器的CPU结构如:x86_64、aarch64或者其他
  • 选择需要的版本

docker-compose下载

  • 点击上方链接进入到docker-compose的releases页面

  • 选择对应docker版本的docker-compose

    • releases说明里有对应的docker版本号,会写当前compose是用哪一个版本的docker测试的,不行就都下最新版

开始安装

  1. 将包上传到服务器上任意目录

    • 例如:/opt/package,(没有请创建)
  2. 创建一个docker.service​文件

    shell 复制代码
    touch docker.service
  3. 复制以下内容到docker.service​内,并修改--data-root="/{your-path}/docker"​,指定docker生成目录(路径后的docker目录需手动创建)

    toml 复制代码
    [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 --default-ulimit nofile=65535:65535 --data-root="/{your-path}/docker"
    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
  4. 移动docker.service​到​ /usr/lib/systemd/system/ ​​目录下,将docker作为系统进程进行管理

    shell 复制代码
    mv docker.service /usr/lib/systemd/system/
  5. 将下载好的docker-compse​文件赋予可执行权限、改名、并移动到​/usr/bin​目录下

    shell 复制代码
    # 赋予可执行权限
    chmod +x docker-compose-linux-XXXX
    
    # 更名为 docker-compose
    mv docker-compose-linux-XXXX docker-compose
    
    # 移动到全局命令目录下
    mv docker-compose /usr/bin
  6. 解压docker​包,将解压出来的包移动或复制到 /usr/bin​ 目录下

    shell 复制代码
    # 解压
    tar -zxf docker-XX.XX.XX.tgz
    
    # 复制
    cp docker/* /usr/bin
  7. 查看docker、docker-compose版本

    shell 复制代码
    # 查看docker版本
    docker -v
    
    # 查看docker-compose版本
    docker-compose -v
  8. 执行以下命令:设置自启动、启动服务、查询服务状态

    shell 复制代码
    # 设置docker自启动
    systemctl enable docker.service 
    
    # 启动docker服务
    systemctl start docker.service 
    
    # 查询docker状态
    systemctl status docker.service
  9. 可以准备一个hello-world​的镜像,当docker安装好后试一下是否安装成功

    shell 复制代码
    docker run hello-world
    • 显示以下信息则docker安装成功

    doc 复制代码
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (arm64v8)
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
    
    To try something more ambitious, you can run an Ubuntu container with:
     $ docker run -it ubuntu bash
    
    Share images, automate workflows, and more with a free Docker ID:
     https://hub.docker.com/
    
    For more examples and ideas, visit:
     https://docs.docker.com/get-started/

相关推荐
likfishdn13 分钟前
Linux的文件与目录管理
linux·运维·服务器
chian-ocean33 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=35 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
Dontla1 小时前
Docker run --add-host参数解析(在容器启动时向/etc/hosts文件中添加自定义的主机名与IP映射)(适用于临时调试或测试)
tcp/ip·docker·容器
西西小飞龙1 小时前
Docker和K8S中pod、services、container的介绍和关系
docker·容器·kubernetes
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
kngines1 小时前
【实战 ES】实战 Elasticsearch:快速上手与深度实践-1.3.1单节点安装(Docker与手动部署)
大数据·elasticsearch·docker
北京耐用通信1 小时前
航空装配自动化神器Ethercat转profient网关搭配机器人精准控制
运维·机器人·自动化
吃汤圆的抹香鲸2 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
崔lc4 小时前
linux中安装部署Jenkins,成功构建springboot项目详细教程
运维·jenkins