构建错误的日志为:
TASK [Docker Remove Orphans] ***************************************************
fatal: [4]: FAILED! => {"changed": true, "cmd": "docker compose up -d --remove-orphans", "delta": "0:00:00.407026", "end": "2025-04-02 18:24:25.290915", "msg": "non-zero return code", "rc": 1, "start": "2025-04-02 18:24:24.883889", "stderr": "time=\"2025-04-02T18:24:25Z\" level=warning msg=\"/home/app/zchub/zchub-service/docker-compose.yaml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion\"\nunable to get image 'repo-docker.isharkfly.com/zchub-service:0.0.1-SNAPSHOT': permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get \"http://%2Fvar%2Frun%2Fdocker.sock/v1.48/images/repo-docker.isharkfly.com/zchub-service:0.0.1-SNAPSHOT/json\": dial unix /var/run/docker.sock: connect: permission denied", "stderr_lines": ["time=\"2025-04-02T18:24:25Z\" level=warning msg=\"/home/app/zchub/zchub-service/docker-compose.yaml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion\"", "unable to get image 'repo-docker.isharkfly.com/zchub-service:0.0.1-SNAPSHOT': permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get \"http://%2Fvar%2Frun%2Fdocker.sock/v1.48/images/repo-docker.isharkfly.com/zchub-service:0.0.1-SNAPSHOT/json\": dial unix /var/run/docker.sock: connect: permission denied"], "stdout": "", "stdout_lines": []}
针对上面的错误需要以 sudo 的方式来运行。
修改 playbook 来以 sudo 运行即可。