Loading... ## 前言 折腾homelab, 很多时候都需要用到docker部署各类的Apps, 这里记录下快速配置过程. ## 部署 <div class="tip inlineBlock info"> 以下内容在Ubuntu/Debian中验证OK </div> *一键安装脚本* * 下载脚本依赖`curl`, 可能需要提前安装 * 配置国内加速源, 需要修改配置, 需要安装常用的编辑器, 如`vim` * 原始官方部署教程[链接](https://docs.docker.com/engine/install/ubuntu/) ```bash # 可选 apt install -y curl vim # 官方脚本, 指定使用Aliyun加速, root权限执行 curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun ~$ docker --version Docker version 25.0.0, build e758fe5 ``` *(可选)普通用户授权docker权限* ```bash # 注意登录用户身份 sudo usermod -aG docker $USER # 需要登出再重新登录才生效(实测需要重启生效) # 没有生效前 id 与 id $USER 显示不一致 # id $USER 或 cat /etc/group | grep docker # 查看 newgrp - docker # 更新用户组 很重要(临时生效) docker ps # 测试docker命令是否可以使用sudo正常使用 ``` *(可选)配置国内源* * 以Aliyun为例, 官方为每个注册用户提供的加速地址信息参见 ```bash # 配置aliyun镜像加速 mkdir -p /etc/docker tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://ohjd26wr.mirror.aliyuncs.com"] } EOF systemctl daemon-reload systemctl restart docker ``` *测试镜像拉取&运行容器* ```bash # 测试镜像拉取&容器运行 docker run hello-world ``` ![docker hello-world](https://zoe.red/usr/uploads/2024/01/4021144246.png) ## 管理 portainer是一款流行的web端docker管理工具, 简单易用且能够满足个人折腾的需要, 下面介绍如何部署. *官方版本* * 参考[链接](https://docs.portainer.io/start/install-ce/server/docker/linux) ```bash # 1. 拉取镜像 docker pull portainer/portainer-ce:latest # 2.创建磁盘卷(可选) docker volume create portainer_data # 3. 创建容器 # 端口组合二选一即可, 粘贴代码前注意先删除 自#之后的注释, 避免格式问题 docker run -d --name portainer --restart=always \ -p 8000:8000 -p 9443:9443 \ # https使用, 仅使用http的话可以尝试注释掉 -p 9000:9000 \ # 使用传统的http端口 -v /var/run/docker.sock:/var/run/docker.sock \ -v portainer_data:/data portainer/portainer-ce:latest ``` *汉化版本* * 241012补充: 最新为v2.19.4, 作者后续也不再更新, 详情看[作者说明](https://hub.docker.com/r/6053537/portainer-ce) ```bash docker volume create portainer_data docker run -d --name portainer-zh --restart=always \ -p 9000:9000 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v portainer_data:/data 6053537/portainer-ce:latest ``` *节点IP* * 节点上部署的容器, 端口映射链接地址, 默认为 0.0.0.0:端口, 此处设置后打开为设定ip:端口 ![设置节点IP, 1](https://zoe.red/usr/uploads/2024/02/114578829.png) ![设置节点IP, 2](https://zoe.red/usr/uploads/2024/02/1997723228.png) 效果: 节点下容器的端口链接地址 ![效果: ](https://zoe.red/usr/uploads/2024/02/2599519555.png) THE END 本文作者:将夜 本文链接:https://zoe.red/2024/174.html 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。 最后修改:2024 年 10 月 12 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏