Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Encountered When Building Multi-Architecture Docker Images Using docker-maven-plugin #1785

Open
alankritaman opened this issue May 9, 2024 · 1 comment

Comments

@alankritaman
Copy link

Description

Encountered an error while attempting to utilize the docker-maven-plugin for building multi-architecture images in GitLab. The error message received was:

ERROR: could not create a builder instance with TLS data loaded from environment. Please use `docker context create <context-name>` to create a context for the current environment and then create a builder instance with the context set to <context-name>

Following advice provided, I executed the following commands before initiating the build process:

- docker context create tls-environment
- docker buildx create --name my-builder --driver docker-container --use tls-environment

Despite implementing these commands, the error persisted. Attempting to build manually using the following command was successful:

docker buildx build --push --platform linux/amd64,linux/arm64 -t tmp .

However, when attempting to execute the build command through Maven (mvn), the same error continued to occur.

Even after attempting to manually create a Docker context using the following exec-maven-plugin code, the error persisted unchanged.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>${exec-maven-plugin.version}</version>
    <executions>
      <execution>
        <id>create-docker-context</id>
        <phase>pre-build</phase>  <goals>
          <goal>exec</goal>
        </goals>
        <configuration>
          <command>
            docker
            context
            create
            --name
            ${docker.context}
          </command>
        </configuration>
      </execution>
      </executions>       
</plugin>

Info

  • docker-maven-plugin version :
  • Maven version (mvn -v) :
Java version: 1.8.0_402, vendor: IcedTea, runtime: /usr/lib/jvm/java-1.8-openjdk/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "6.3.13-linuxkit", arch: "amd64", family: "unix"
  • Docker version :
Client:
 Version:           26.1.1
 API version:       1.45
 Go version:        go1.21.9
 Git commit:        4cf5afa
 Built:             Tue Apr 30 11:46:57 2024
 OS/Arch:           linux/amd64
 Context:           default
Server: Docker Engine - Community
 Engine:
  Version:          26.1.1
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.9
  Git commit:       ac2de55
  Built:            Tue Apr 30 11:48:27 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.7.15
  GitCommit:        926c9586fe4a6236699318391cd44976a98e31f1
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
  • If it's a bug, how to reproduce :
Add following to pom.xml
 <properties>
   <docker.platforms></docker.platforms>
 </properties>

and 
<buildx>
  <platforms>
    <platform>linux/amd64</platform>
    <platform>linux/arm64</platform>
  </platforms>
</buildx>
  • If it's a feature request, what is your use case :
  • Sample project : [GitHub Clone URL]
@alankritaman
Copy link
Author

Discovered a workaround in the GitLab configuration to address the issue. Removed the docker-certs section from the previous configuration.

Previous Configuration:

config.template.toml: |
  [[runners]]
    [runners.kubernetes]
      namespace = "gitlab"
      tls_verify = false
      image = "docker:19"
      privileged = true
    [[runners.kubernetes.volumes.empty_dir]]
      name = "docker-certs"
      mount_path = "/certs/client"
      medium = "Memory"

New Configuration:

config.template.toml: |
  [[runners]]
    [runners.kubernetes]
      image = "docker:26.1"
      privileged = true
      namespace = "gitlab"
      tls_verify = false

Additionally, updated the gitlab-ci.yml file with the following configuration:

stage: mvnbuild
services:
  - name: docker:dind
    command: ["--tls=false"]

variables:
  DOCKER_HOST: "tcp://docker:2375"
  DOCKER_TLS_CERTDIR: ""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant