我们在使用 jenkins 构建我们的一个 docker 项目的时候提示:
[error] failed to execute goal io.fabric8:docker-maven-plugin:0.40.2:build (default) on project api: execution default of goal io.fabric8:docker-maven-plugin:0.40.2:build failed: no given, no docker_host environment variable, no read/writable '/var/run/docker.sock' or '//./pipe/docker_engine' and no external provider like docker machine configured -> [help 1]
[error]
[error] to see the full stack trace of the errors, re-run maven with the -e switch.
[error] re-run maven using the -x switch to enable full debug logging.
[error]
[error] for more information about the errors and possible solutions, please read the following articles:
通过日志我们了解到上面的问题就是 jenkins 没有办法调用 docker 的构建命令。
问题和解决
我们尝试了很多种方法来解决这个问题。
包括有重新安装 docker,重新写脚本等等,都发现没有办法解决。
然后我们在下载的 git 代码中直接使用 root 账号进行编译,发现是没有问题的。
这个就让我想到,有没有可能是因为 jenkins 的用户没有访问 docker 的权限。
因为 jenkins 的编译是在 jenkins 自己这个账号下运行的的。
随后我们运行了下面 2 个命令。
sudo gpasswd -a jenkins docker
sudo usermod -a -g docker jenkins
上面命令运行后的输出如下:
[[email protected] usvisatrack-api-service]# sudo gpasswd -a jenkins docker
adding user jenkins to group docker
[[email protected] usvisatrack-api-service]# sudo usermod -a -g docker jenkins
简单来说,上面 2 个命令执行的结果就是吧 jenkins 这个用户加到 docker 这个用户组里面。
在完成上面的配置后,重启 jenkins。
然后再进行编译,我们发现提示没有办法执行 docker 打包的问题就解决了。
相关推荐
jenkins-pipeline-docker, 带有jenkins管道插件和 docker的容器构建环境 采用jenkins管道插件和 docker的容器环境。这里代码与这里博客帖子相关:...
项目基本结构是springboot,集成了docker-maven插件实现build完的镜像上传到私服,然后用 jenkins构建实现docker集群一键自动化部署
基于jenkins gitlab docker实现springboot项目自动部署
企业级docker jenkinspipeline gitlabci_cd工作流自动化构建实践
jenkins_docker_pipeline_tutorial1:教程的代码库:docker化jenkins 2设置并将其与sonarqube结合使用以创建现代的声明式构建管道
docker jenkins gitlab的持续集成,持续交付,使开发,运维,测试一体化,研发:开发流程高效,稳定,快速,交付结果可预测,运维:容器监控,自动化运维,降低维护成本
jenkins_service_host和jenkins_service_port :如果前一个不存在,则将用于组成该url。 jenkins_tunnel :( host:port )连接到此从属主机和端口而不是jenkins服务器 jenkins_slave_service_host和jen
docker jenkins gitlab maven springboot&springcloud;自动化构建
章节四:jenkins docker springcloud微服务项目持续集成 1. docker基础 2. dockerfile脚本构建docker镜像 3. docker私有仓库harbor安装和使用 4. jenkins集群部署springcloud微服务 章节五:jenkins kubernetes ...
jenkins svn docker springcloud实现可持续自动化微服务
jenkins脚本..bash_aliases
詹金斯 基于 cocoon/base 的 jenkins docker 镜像 机器人框架 皮詹金斯 机器人客户端 在沙箱中播放图像 docker run -d -8020:...在 ${docker_host}:8020 打开浏览器 作品 debian:wheezy cocoon/base cocoon/jenkins
jenkins gradle实现android_studio自动化构建打包
jenkins-php docker 这是另一个 jenkins-php 模板 docker。...运行镜像docker run -d -p -v /var/docker/jenkins-php-docker:/var/jenkins_home:rw naxhh/jenkins-php-docker docker 公开了端口8080因此只需转到h
它是创建本地docker注册表并从中获取jenkins构建所需映像的买球软件推荐的解决方案之一。你需要本地docker注册表查看在docker中启动jenkins 要使用本地注册表在docker中启动jenkins: 创建自定义出价图像docker build dind -t ...
码头工人詹金斯jenkins 的 docker 镜像此 docker 映像包含: java 和 maven 来构建你的 java 项目active directory 身份验证的默认配置使用私有 ssh 密钥的默认配置访问 git 服务器如何配置 active directory 身份...
jenkins docker image docker客户端 ... docker run -d -p -v /home/jenkins:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock ogirardot/jenkins-with-docker 更多信息? 在docker注册表上
jenkins mavn git docker-compose swarm 构建持续集成及一键式部署
docker_jenkins_backend
gitllab jenkins docker harbor 自动化部署流程