chilianyi 你这个环境容器运行时用的 docker 还是 container。 可以通过 查看 configmap:jenkins-casc-config,中这个 nodejs 对应的 image 来看,image id 带不带 podman 后缀。 如果带,说明这个环境,k8s 是用的 containerd
chilianyi koalawangyang 其他的不变,containerd 的场景,agent image 里没有 装 docker,可以用 podman 命令, 或者 alias docker=podman,然后用 docker 操作。
koalawangyang chilianyi 感谢大佬回复,我在原有环境里用 alias docker=podman 重新运行流水线,但这次又提示 /home/jenkins/agent/workspace/cicdhfmxm/xxl-job-admin@tmp/durable-93156516/script.sh: line 3: podman: command not found
koalawangyang koalawangyang 我也查看了 configmap:jenkins-casc-config ,其中 maven 对应的 image 带 podman 的后缀。 - name: "maven" namespace: "kubesphere-devops-worker" label: "maven" nodeUsageMode: "EXCLUSIVE" idleMinutes: 0 containers: - name: "maven" image: "kubesphere/builder-maven:v3.2.0-podman" command: "cat" args: "" ttyEnabled: true privileged: true resourceRequestCpu: "100m" resourceLimitCpu: "4000m" resourceRequestMemory: "100Mi" resourceLimitMemory: "8192Mi"
koalawangyang chilianyi 感谢大佬回复,是的,不然还有别的选择么 stage('Build Docker Image') { steps { container('maven') { withCredentials([usernamePassword(credentialsId : "docker-hub" ,passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,)]) { sh ''' alias docker=podman docker build --build-arg APP_DIR="${APP_DIR}" -t ${REGISTRY}/${DOCKERHUB_NAMESPACE}/${APP_NAME}:${GIT_BRANCH}-${BUILD_NUMBER}-${BUILD_TIME} . echo "${DOCKER_PASSWORD}" | docker login ${REGISTRY} -u "${DOCKER_USERNAME}" --password-stdin docker push ${REGISTRY}/${DOCKERHUB_NAMESPACE}/${APP_NAME}:${GIT_BRANCH}-${BUILD_NUMBER}-${BUILD_TIME} ''' } } } }
chilianyi koalawangyang 我用这种环境试了下,可以操作,有什么不同吗? pipeline { agent { node { label 'maven' } } stages { stage('stage-rbzgp') { agent none steps { container('maven') { sh ''' alias docker=podman docker ps podman ps ''' } } } } } 实在不行,sleep 3600s,然后进到容器里执行下试试,我这进到容器是正常的。
koalawangyang chilianyi 感谢大佬帮助,我这边问题已经暂时解决,将详情发布到另外一个帖子中了: https://kubesphere.io/forum/d/9342-k8s-cri-containerd-devops/8