Gradle Docker插件连接超时
我正在尝试使用bmuschko / gradle-docker-plugin来创build和构build一个图像。 Dockerfile被创build,但我似乎无法从它build立一个图像。 我在Centos 7上。
创buildDockerfile:
task createBaseImage(type: Dockerfile) { destFile = project.file('docker/base/Dockerfile') from 'java:8' runCommand 'apt-get update' runCommand 'apt-get -qq -y install python3 python3-dev python3-pip' }
build立图像:
task buildBaseImage(type: DockerBuildImage) { dependsOn createBaseImage inputDir = createBaseImage.destFile.parentFile tag = 'the/tag' }
当运行buildBaseImage任务./gradlew buildBaseImage --info
,执行挂起并最终失败:
org.apache.http.conn.ConnectTimeoutException: Connect to 192.168.59.103:2376 [/192.168.59.103] failed: Connection timed out
我怀疑是从我的示例中复制了docker closure的问题:
docker { url = 'http://192.168.59.103:2376' registryCredentials { url = 'https://index.docker.io/v1' username = '${docker_user}' password = '${docker_password}' email = 'email@example.com' } }
我试过不同的url,端口等,但问题依然存在。 任何想法是什么导致这个问题?
通过使用不同的Gradle插件解决了这个问题。 图像可以以类似和简单的方式构build:
task buildBaseImage(type: Docker) { baseImage 'java:8' applicationName = "app-name" tagVersion = 'latest' runCommand "apt-get update" runCommand "apt-get -qq -y install python3 python3-dev python3-pip" }
然后通过以下方式推送到Docker Hub:
task pushBaseImage(type: Exec, dependsOn: 'buildBaseImage') { executable 'docker' args = ['push','-f', getGroup() + '/my-base'] }
使用强制跳过推送确认。
docker推送 – 帮助
-f,–force = false在没有确认的情况下推送到公共registry
这是我解决连接问题的方法。
以下是所需的configuration:
apply plugin: 'docker' buildscript { repositories { jcenter() } dependencies { classpath 'se.transmode.gradle:gradle-docker:1.2' } } group = "myGroup" docker { maintainer 'Maintainer "maintainer@example.com"' }
- Webpack,asp.net核心,docker:用dotnetdebugging或发布构buildwebpack
- 用Docker构buildAngularDart
- Dockerfile运行命令返回“没有这样的文件或目录”
- Docker依赖问题:Rake中止! LoadError:无法加载这样的文件 – sqlite3 / sqlite3_native
- 如何使Cake-build的示例项目在Docker上工作
- dockerbuild设与Dockerfile,但图像没有名称或标记
- 企业私人Dockerregistry最佳实践
- 如何在不同的机器上运行docker容器
- 在Docker镜像/容器中安装和使用Gradle