Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-65216

Daemonless Docker Build

XMLWordPrintable

      When building in Kubernetes it is common to be building a docker image in a daemon less environment using img or kaniko. This is not compatible with gathering build information with the Artifactory plugin because it looks like the plugin requires the docker socket.

      When building an container image inside of the img project on Kubernetes:

      pipeline {
          agent {
              kubernetes {
                  defaultContainer 'test'
                  yaml """
                      apiVersion: v1
                      kind: Pod
                      metadata:
                        annotations:
                          container.apparmor.security.beta.kubernetes.io/img: unconfined
                          container.seccomp.security.alpha.kubernetes.io/img: unconfined
                      spec:
                        securityContext:
                          runAsUser: 1000
                          runAsGroup: 1000
                        containers:
                          - name: img
                            image: r.j3ss.co/img
                            imagePullPolicy: Always
                            command: [sh, -c, 'sleep 8h ; echo exiting due to timeout >&2']
                            tty: true
                            resources:
                              requests:
                                memory: 2Gi
                                cpu: 500m
                              limits:
                                memory: 2Gi
                                cpu: 2
                      """
              }
          }
          stages {
              stage('Build') {
                  steps {
                      script {
                          def artifactoryServer = Artifactory.server(<server-id>)
                          def artifactoryDocker = Artifactory.docker(server: artifactoryServer /*, host: "tcp://not-needed-because-using-daemonless:55555" */)
                          def artifactoryBuildInfo = Artifactory.newBuildInfo()
                          artifactoryDocker.push('test-image', 'docker-test-repo', artifactoryBuildInfo)
                      }
                  }
              }
          }
      }
      

      The following error is created:

      hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from ip-**********.ec2.internal/**********:*****
      		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1743)
      		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)
      		at hudson.remoting.Channel.call(Channel.java:957)
      		at org.jfrog.hudson.pipeline.common.docker.utils.DockerAgentUtils.getImageIdFromAgent(DockerAgentUtils.java:291)
      		at org.jfrog.hudson.pipeline.common.executors.DockerExecutor.execute(DockerExecutor.java:59)
      		at org.jfrog.hudson.pipeline.scripted.steps.DockerPushStep$Execution.run(DockerPushStep.java:104)
      		at org.jfrog.hudson.pipeline.scripted.steps.DockerPushStep$Execution.run(DockerPushStep.java:71)
      		at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
      		at hudson.security.ACL.impersonate(ACL.java:290)
      		at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
      		at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      		at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      java.io.FileNotFoundException
      	at io.netty.channel.unix.Errors.throwConnectException(Errors.java:110)
      	at io.netty.channel.unix.Socket.connect(Socket.java:257)
      	at io.netty.channel.epoll.AbstractEpollChannel.doConnect0(AbstractEpollChannel.java:728)
      	at io.netty.channel.epoll.AbstractEpollChannel.doConnect(AbstractEpollChannel.java:713)
      	at io.netty.channel.epoll.EpollDomainSocketChannel.doConnect(EpollDomainSocketChannel.java:87)
      	at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.connect(AbstractEpollChannel.java:555)
      	at io.netty.channel.DefaultChannelPipeline$HeadContext.connect(DefaultChannelPipeline.java:1366)
      	at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:545)
      	at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:530)
      	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.connect(CombinedChannelDuplexHandler.java:497)
      	at io.netty.channel.ChannelOutboundHandlerAdapter.connect(ChannelOutboundHandlerAdapter.java:47)
      	at io.netty.channel.CombinedChannelDuplexHandler.connect(CombinedChannelDuplexHandler.java:298)
      	at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:545)
      	at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:530)
      	at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:512)
      	at io.netty.channel.DefaultChannelPipeline.connect(DefaultChannelPipeline.java:1024)
      	at io.netty.channel.AbstractChannel.connect(AbstractChannel.java:259)
      	at io.netty.bootstrap.Bootstrap$3.run(Bootstrap.java:252)
      	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
      	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
      	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:335)
      	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
      	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
      	at java.lang.Thread.run(Thread.java:748)
      

      Is there any way to gather build information and push to the Artifactory docker repo other than through the docker socket that the plugin uses?

            eyalbe Eyal Ben Moshe
            j_luxworth Jesse S
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: