dron-ci 服务重新安装

今天遇到打包服务器不能工作了,df -lh 看了一下,磁盘占用达到了 87%,服务器的存储不够,后面排查问题发现是 overlayers2 目录占用达到了惊人的 470g,可怕。那接下讲讲 overlay2 目录了

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
Docker  `overlay2` 是一种存储驱动,用于管理镜像和容器层的数据。它的主要作用包括:

1. [**分层存储**`overlay2` 使用分层存储技术,每一层通过本层的哈希值(如 MD5)命名。如果多个镜像或容器共享相同的底层数据,这些数据只会存储一份,从而节省存储空间](https://blog.csdn.net/zxxshaycormac/article/details/120433857)[1](https://blog.csdn.net/zxxshaycormac/article/details/120433857)[2](https://zhuanlan.zhihu.com/p/587283618)

2. [**联合挂载**:当启动容器时,`overlay2` 会从底层目录和上层目录构建联合挂载,以提供给容器文件系统的视图。这意味着容器可以看到一个合并后的文件系统](https://blog.csdn.net/zxxshaycormac/article/details/120433857)[2](https://zhuanlan.zhihu.com/p/587283618)

3. [**高效数据管理**`overlay2` 支持快速的数据复制和移动,使得容器的创建、删除和迁移更加高效](https://blog.csdn.net/zxxshaycormac/article/details/120433857)[3](https://developer.baidu.com/article/details/2812767)

4. [**节省空间**:通过共享相同的底层数据,`overlay2` 可以显著减少磁盘空间的使用](https://blog.csdn.net/zxxshaycormac/article/details/120433857)[1](https://blog.csdn.net/zxxshaycormac/article/details/120433857)[3](https://developer.baidu.com/article/details/2812767)


[如果你遇到 `overlay2` 目录占用空间过大的问题,可以通过删除不需要的镜像和容器,或者检查容器内是否有服务在写入大量数据来进行清理](https://blog.csdn.net/zxxshaycormac/article/details/120433857)[1](https://blog.csdn.net/zxxshaycormac/article/details/120433857)

你在使用 Docker 时有遇到过类似的问题吗?

接下来就是清理 overlay2 目录了

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
清理 Docker  `overlay2` 目录可以帮助释放磁盘空间。以下是一些常见的方法:

1. **清理未使用的镜像和容器**

    - 使用以下命令删除未运行的容器:

        ```bash
        docker container prune -f
        ```

    - 删除未使用的镜像:

        ```bash
        docker image prune -a -f
        ```

2. **清理 Docker 系统**

    - 使用 Docker 内置的命令进行自动空间清理:

        ```bash
        docker system prune -a -f
        ```


    这将清理所有未使用的容器、镜像、卷和网络。

3. **手动清理 `overlay2` 目录**

    - 首先,找到 Docker 的数据根目录(通常是 `/var/lib/docker/overlay2`)。
    - 确定哪些文件和目录占用了大量空间,可以使用以下命令查看:

        ```bash
        du -sh /var/lib/docker/overlay2/*
        ```

    - 删除不需要的文件和目录,但要小心,不要删除正在使用的容器和镜像的数据。
4. **清理容器日志**:

    - 容器日志文件可能会占用大量空间,可以使用以下脚本清理日志:

        ```bash
        #!/bin/bash
        echo "======== Start cleaning Docker containers logs ========"
        logs=$(find /var/lib/docker/containers/ -name *-json.log)
        for log in $logs
        do
            echo "Cleaning log: $log"
            cat /dev/null > $log
        done
        echo "======== End cleaning Docker containers logs ========"
        ```


[这些方法可以帮助你有效地管理和清理 Docker 的 `overlay2` 目录](https://blog.csdn.net/zxxshaycormac/article/details/120433857)[1](https://blog.csdn.net/zxxshaycormac/article/details/120433857)[2](https://blog.csdn.net/Small_StarOne/article/details/123655176)[3](https://bing.com/search?q=%E5%A6%82%E4%BD%95%E6%B8%85%E7%90%86docker%E7%9A%84overlay2%E7%9B%AE%E5%BD%95)。如果你有其他问题或需要进一步的帮助,请随时告诉我!

[](https://blog.csdn.net/zxxshaycormac/article/details/120433857)[1](https://blog.csdn.net/zxxshaycormac/article/details/120433857)[: https://blog.csdn.net/zxxshaycormac/article/details/120433857](https://blog.csdn.net/zxxshaycormac/article/details/120433857) [2](https://blog.csdn.net/Small_StarOne/article/details/123655176)[: https://blog.csdn.net/Small_StarOne/article/details/123655176](https://blog.csdn.net/zxxshaycormac/article/details/120433857) [3](https://bing.com/search?q=%E5%A6%82%E4%BD%95%E6%B8%85%E7%90%86docker%E7%9A%84overlay2%E7%9B%AE%E5%BD%95): https://bing.com/search?q=%e5%a6%82%e4%bd%95%e6%b8%85%e7%90%86docker%e7%9a%84overlay2%e7%9b%ae%e5%bd%95

你平时还遇到哪些 Docker 相关的问题呢?

400 多 g 的文件,删除了几个小时,后来受不了,直接全部删除了,重新安装了一把 docker,但是再这里就遇到一个坑,当安装 docker 的版本是 18.06.3.ce-3.el7 ,因为 docker 的版本太低了,会让 drone 构建服务器总是服务启动,后来,经过不懈努力终于再返回界面找到蛛丝马季,说因为 docker 的版本是 1.37,但是 pipeline 需要的版本是至少 1.40,然后重新安装 docker 服务。注意一下 docker 的版本

查看 docker 版本

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[root@devops local]# docker version
Client: Docker Engine - Community
 Version:           26.1.4
 API version:       1.45
 Go version:        go1.21.11
 Git commit:        5650f9b
 Built:             Wed Jun  5 11:32:04 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          26.1.4
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.11
  Git commit:       de5c9cf
  Built:            Wed Jun  5 11:31:02 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.33
  GitCommit:        d2d58213f83a351ca8f528a95fbd145f5654e957
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

查看安装的 docker 版本

1
2
3
4
5
6
7
[root@devops local]#   yum list installed|grep docker
containerd.io.x86_64             1.6.33-3.1.el7                @docker-ce-stable
docker-buildx-plugin.x86_64      0.14.1-1.el7                  @docker-ce-stable
docker-ce.x86_64                 3:26.1.4-1.el7                @docker-ce-stable
docker-ce-cli.x86_64             1:26.1.4-1.el7                @docker-ce-stable
docker-ce-rootless-extras.x86_64 26.1.4-1.el7                  @docker-ce-stable
docker-compose-plugin.x86_64     2.27.1-1.el7                  @docker-ce-stable

查看可以安装的 docker 版本

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[root@devops local]#  yum list docker-ce --showduplicates | sort -r
 * updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Installed Packages
 * extras: mirrors.aliyun.com
docker-ce.x86_64            3:26.1.4-1.el7                     docker-ce-stable
docker-ce.x86_64            3:26.1.4-1.el7                     @docker-ce-stable
docker-ce.x86_64            3:26.1.3-1.el7                     docker-ce-stable
docker-ce.x86_64            3:26.1.2-1.el7                     docker-ce-stable
docker-ce.x86_64            3:26.1.1-1.el7                     docker-ce-stable
docker-ce.x86_64            3:26.1.0-1.el7                     docker-ce-stable
docker-ce.x86_64            3:26.0.2-1.el7                     docker-ce-stable
docker-ce.x86_64            3:26.0.1-1.el7                     docker-ce-stable
docker-ce.x86_64            3:26.0.0-1.el7                     docker-ce-stable
docker-ce.x86_64            3:25.0.5-1.el7                     docker-ce-stable
docker-ce.x86_64            3:25.0.4-1.el7                     docker-ce-stable
docker-ce.x86_64            3:25.0.3-1.el7                     docker-ce-stable
docker-ce.x86_64            3:25.0.2-1.el7                     docker-ce-stable
docker-ce.x86_64            3:25.0.1-1.el7                     docker-ce-stable
docker-ce.x86_64            3:25.0.0-1.el7                     docker-ce-stable
docker-ce.x86_64            3:24.0.9-1.el7                     docker-ce-stable
docker-ce.x86_64            3:24.0.8-1.el7                     docker-ce-stable
docker-ce.x86_64            3:24.0.7-1.el7                     docker-ce-stable
docker-ce.x86_64            3:24.0.6-1.el7                     docker-ce-stable
docker-ce.x86_64            3:24.0.5-1.el7                     docker-ce-stable
docker-ce.x86_64            3:24.0.4-1.el7                     docker-ce-stable
docker-ce.x86_64            3:24.0.3-1.el7                     docker-ce-stable
docker-ce.x86_64            3:24.0.2-1.el7                     docker-ce-stable
docker-ce.x86_64            3:24.0.1-1.el7                     docker-ce-stable
docker-ce.x86_64            3:24.0.0-1.el7                     docker-ce-stable
docker-ce.x86_64            3:23.0.6-1.el7                     docker-ce-stable
docker-ce.x86_64            3:23.0.5-1.el7                     docker-ce-stable

这里我们安装的 docker 版本为 26.1.4-1.el7 ,安装命令为

1
 yum install -y docker-ce-26.1.4-1.el7

这样服务正常安装了。 下面介绍一下文件把: [root@devops local]# tree . ├── docker-compose.yml ├── drone-data ├── drone.env ├── drone-example.env └── README.md

  1. docker-compose.yml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
[root@devops local]# cat docker-compose.yml
version: '3.5'

services:
  drone-server:
    image: huangxiaofenglogin/drone:linux-amd64
    ports:
      - 8000:80
      - 9000:443
    networks:
      - drone
    volumes:
      - ./drone-data:/var/lib/drone/
      - /var/run/docker.sock:/var/run/docker.sock
    env_file:
      - ./drone.env
    restart: always
    environment:
      - DRONE_AGENTS_ENABLED=true
      - DRONE_SERVER_HOST=190.7.20.39:8000
      - DRONE_SERVER_PROTO=http
      - DRONE_OPEN=true
      - DRONE_DEBUG=true
      - DRONE_LOGS_DEBUG=true
      - DRONE_LOGS_TRACE=true

  drone-agent:
    image:  drone/drone-runner-docker:1
    command: agent
    restart: always
    depends_on:
      - drone-server
    networks:
      - drone
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    env_file:
      - ./drone.env
    environment:
      - DRONE_RPC_SERVER=drone-server
      - DRONE_RPC_HOST=drone-server

networks:
  drone:
    name: drone_network

drone.env

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
[root@devops local]# cat drone.env
# Drone secret key, used for private communication between agents and web UI
DRONE_USER_CREATE=username:hxf168482,machine:false,admin:true
DRONE_USER_FILTER=
DRONE_SERVER_HOST=190.7.20.39:8000
DRONE_SERVER_PROTO=http
DRONE_GITLAB_CLIENT_ID=0f9281e5f44624a32133865d86d013877458823d4ffdfdcb4787d7ca95d0d0
DRONE_GITLAB_CLIENT_SECRET=869720d158c92f05d8f5229a957dcc221c16d88418e64e78b2e95002b1b89e
DRONE_GITLAB_SERVER=http://190.7.20.44
DRONE_GITLAB_SKIP_VERIFY=false
DRONE_RPC_SECRET=1
DRONE_RPC_PROTO=http
DRONE_RUNNER_CAPACITY=10

启动运行即可。 遇到的问题报错

Cannot transition status via :enqueue from :pending #885

这个是因为 docker 版本的问题,造成启动 pipeline 就是 error,刚开始怀疑是 gitlab 出问题了,后来查看 gitlab 没有发现异常 来看看 coplot 给出的答案

This error typically occurs when there’s an attempt to change the status of a job in GitLab or Jenkins in a way that isn’t allowed by the system. Here are a few potential solutions based on similar issues others have encountered:

  1. Check for Duplicate Webhooks: Ensure that there are no duplicate webhooks registered for the same event in your GitLab project settings. Duplicate webhooks can cause conflicts and lead to this error1.
  2. Review Pipeline Triggers: If multiple builds of your pipeline start very quickly, it might cause status update conflicts. Try to ensure that builds are not triggered too closely together1.
  3. API Restrictions: The GitLab API has certain restrictions on status transitions. For example, you cannot transition a status from pending to enqueue. Make sure your API calls are compliant with these restrictions2.
  4. Check Integration Settings: If you’re using an integrated Kubernetes cluster within your CI/CD pipeline, ensure that the integration is set up correctly and that all necessary resources are created successfully3.

If these steps don’t resolve the issue, could you provide more details about your setup? For example, are you using Jenkins, GitLab, or another CI/CD tool? This information can help in providing a more targeted solution.

可以看出来 ai,也不能直接找出这种简单的问题的答案。

This error typically occurs when there’s an attempt to change the status of a job in GitLab or Jenkins in a way that isn’t allowed by the system. Here are a few potential solutions based on similar issues others have encountered:

  1. Check for Duplicate Webhooks: Ensure that there are no duplicate webhooks registered for the same event in your GitLab project settings. Duplicate webhooks can cause conflicts and lead to this error1.
  2. Review Pipeline Triggers: If multiple builds of your pipeline start very quickly, it might cause status update conflicts. Try to ensure that builds are not triggered too closely together1.
  3. API Restrictions: The GitLab API has certain restrictions on status transitions. For example, you cannot transition a status from pending to enqueue. Make sure your API calls are compliant with these restrictions2.
  4. Check Integration Settings: If you’re using an integrated Kubernetes cluster within your CI/CD pipeline, ensure that the integration is set up correctly and that all necessary resources are created successfully3.(这个看着还有点像,说是版本的问题)

If these steps don’t resolve the issue, could you provide more details about your setup? For example, are you using Jenkins, GitLab, or another CI/CD tool? This information can help in providing a more targeted solution. docker 清理目录 安装 portainer,手动操作删除不用的容器,以及镜像

docker 安装教程一堆

我这里使用 dokcer-compose 部署的所以下面是配置

docker pull portainer/portainer

docker run -p 9000:9000 -p 8000:8000 –name portainer –restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /mnt/portainer:/data -d portainer/portainer

portainer:

image: portainer/portainer restart: always

ports:

  • “9000:9000”

volumes:

  • /var/run/docker.sock:/var/run/docker.sock

  • /data/docker/portainer/data:/data

clip_image002.jpg ![[image-20240920145229803.jpeg]]

up -d 起来以后 nginx 把端口搞出来,访问丫的把那些【unuse】的全【remove】完事

再回去看磁盘占用 终于可以放心的划水啦~~~

image.png ![[image-20240920145240824.png]]

centos7 为 docker 配置 overlay 存储驱动https://blog.csdn.net/kjh2007abc/article/details/90554099 配置 docker 的 daemon.json

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
{
"registry-mirrors": [
   "https://docker.registry.cyou",
   "https://docker-cf.registry.cyou",
   "https://dockercf.jsdelivr.fyi",
   "https://docker.jsdelivr.fyi",
   "https://dockertest.jsdelivr.fyi",
   "https://mirror.aliyuncs.com",
   "https://dockerproxy.com",
   "https://mirror.baidubce.com",
   "https://docker.m.daocloud.io",
   "https://docker.nju.edu.cn",
   "https://docker.mirrors.sjtug.sjtu.edu.cn",
   "https://docker.mirrors.ustc.edu.cn",
   "https://mirror.iscas.ac.cn",
   "https://docker.rainbond.cc"
 ]
}

重启 docker 服务。 https://blog.csdn.net/llc580231/article/details/139979603

添加 yum 源

1
2
yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo(中央仓库)
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo(阿里仓库)
Licensed under CC BY-NC-SA 4.0
最后更新于 Jan 06, 2025 05:52 UTC
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计
Caret Up