spring-boot:build-image behind a proxy

Viewed 1176

I'm trying to follow building a docker image with spring boot 2.3.0 from behind a proxy.

According to the docs https://docs.spring.io/spring-boot/docs/2.3.0.RELEASE/maven-plugin/reference/html/#build-image-example-builder-configuration I need something like

<?xml version="1.0" encoding="UTF-8"?>
<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <version>2.3.0.RELEASE</version>
  <configuration>
    <image>
      <env>
        <HTTP_PROXY>http://proxy.example.com</HTTP_PROXY>
        <HTTPS_PROXY>https://proxy.example.com</HTTPS_PROXY>
      </env>
    </image>
  </configuration>
</plugin>

But I couldn't get that to work. However I could get it to work when prefixing the variables with BPL_ like below

<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <version>2.3.0.RELEASE</version>
  <configuration>
    <image>
      <env>
        <BPL_HTTP_PROXY>http://proxy.example.com</BPL_HTTP_PROXY>
        <BPL_HTTPS_PROXY>https://proxy.example.com</BPL_HTTPS_PROXY>
      </env>
    </image>
  </configuration>
</plugin>

So it this a bug, or something that I don't understand.

Even better, could this be specified outside the pom like from command line? I'm using powershell.

1 Answers

You are almost there, according to https://docs.spring.io/spring-boot/docs/2.5.6/maven-plugin/reference/htmlsingle/#build-image.examples.builder-configuration use HTTP_PROXY

<groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
        <image>
          <env>
            <HTTP_PROXY>http://some.proxy:3011</HTTP_PROXY>
            <HTTPS_PROXY>http://some.proxy:3011</HTTPS_PROXY>
          </env>
        </image>
 </configuration>

If you have the proxy is on your host and you want the build pack to use it, you can set <HTTP_PROXY>http://host.docker.internal:3011</HTTP_PROXY> and <HTTPS_PROXY>http://host.docker.internal:3011</HTTPS_PROXY> the host.docker.internal is the ip of the host machine for commands that are running inside the container

Related