No download progress shown when running as part of "podman build" or "docker build"

169 Views Asked by At

Given the following Dockerfile which runs a sbt update command as part of the image construction:

FROM eclipse-temurin:11-jre-jammy

# Install git
RUN apt-get update && \
  apt-get install -y git && \
  rm -rf /var/lib/apt/lists/* && \
  git --version

# Mandatory as sbt cannot run from /root anyway
WORKDIR /build

# Install sbt
ARG SBT_VERSION=1.9.7
RUN \
  curl -k -L -o sbt-$SBT_VERSION.deb https://repo.scala-sbt.org/scalasbt/debian/sbt-$SBT_VERSION.deb && \
  dpkg -i sbt-$SBT_VERSION.deb && \
  rm sbt-$SBT_VERSION.deb && \
  apt-get update && \
  apt-get install sbt && \
  rm -rf /var/lib/apt/lists/* && \
  sbt sbtVersion

# Download some sbt project
RUN git clone https://github.com/leanovate/play-mockws.git

# Run a sbt command that should give plenty of output
RUN cd play-mockws && sbt update

When building the image with podman build --no-cache ., the sbt command doesn't give as much output as it does when running outside of a Dockerfile.

Here's the output as part of image build:

...
STEP 6/7: RUN git clone https://github.com/leanovate/play-mockws.git
Cloning into 'play-mockws'...
--> 1ae889e2fe5b
STEP 7/7: RUN cd play-mockws && sbt update
[info] welcome to sbt 1.9.7 (Eclipse Adoptium Java 11.0.21)
[info] loading settings for project play-mockws-build from plugins.sbt ...
[info] loading project definition from /build/play-mockws/project
[info] loading settings for project play-mockws from build.sbt ...

<HERE-MISSING-LOT-OF-OUTPUT>

[info] set current project to play-mockws (in build file:/build/play-mockws/)
[success] Total time: 14 s, completed Nov 23, 2023, 4:12:50 PM
COMMIT
--> fc9820272ac3

Whereas doing the same commands outside of the build context/scenario gives plenty of output (like all the stuff that sbt downloads).

For instance, commenting the last line (the sbt update command) of the Dockerfile above:

- RUN cd play-mockws && sbt update
+ # RUN cd play-mockws && sbt update

And building the image again to then exec into it:

podman build . -t testsbt

podman run -it testsbt bash

> cd play-mockws
> sbt update

This gives output like the following:

[info] welcome to sbt 1.9.7 (Eclipse Adoptium Java 11.0.21)
[info] loading settings for project play-mockws-build from plugins.sbt ...
[info] loading project definition from /build/play-mockws/project
https://repo1.maven.org/maven2/com/github/sbt/sbt-github-actions_2.12_1.0/0.19.0/sbt-github-actions_2.12_1.0-0.19.0.pom
  100.0% [##########] 3.0 KiB (4.5 KiB / s)
https://repo1.maven.org/maven2/org/scalameta/sbt-scalafmt_2.12_1.0/2.5.2/sbt-scalafmt_2.12_1.0-2.5.2.pom
  100.0% [##########] 2.9 KiB (4.4 KiB / s)
https://repo1.maven.org/maven2/org/scoverage/sbt-coveralls_2.12_1.0/1.3.11/sbt-coveralls_2.12_1.0-1.3.11.pom
  100.0% [##########] 3.8 KiB (5.7 KiB / s)
https://repo1.maven.org/maven2/org/scoverage/sbt-scoverage_2.12_1.0/1.8.2/sbt-scoverage-1.8.2.pom
  100.0% [##########] 2.3 KiB (47.4 KiB / s)
...

I would expect to have this same output when running sbt update as part of podman build.


To be noted that the same happens with Docker, it's not specific to podman. It's likely related to how sbt prints stuff if it detects a terminal or not.

Then the question would be: how to get a complete detailed output when running sbt commands as part of a podman build.

1

There are 1 best solutions below

1
On

Note the issue is reproducible outside of Docker or podman with just sbt update | cat (as opposed to plain sbt update). Adding the pipe severs sbt's connection to the terminal, causing it to no longer display an interactive progress meter. (And then the lack of a progress meter results in no output at all.)

I'm not sure all the possible solutions or workarounds might be, but here's one workaround. If you run sbt with -debug, you'll see output like:

[debug] downloaded https://repo1.maven.org/maven2/org/scalameta/munit_3/1.0.0-M10/munit_3-1.0.0-M10.jar
[debug] downloaded https://repo1.maven.org/maven2/org/nibor/autolink/autolink/0.6.0/autolink-0.6.0.jar

so problem solved in a sense, except you'll also get a lot of other debug level output that you don't want. You could run sbt -debug update and then switch back to info level logging, which would partway solve the problem — you'd still get a bunch of extra output before the "downloaded" lines.

Anyway, as I say, perhaps some better solution exists. If you want to investigate the problem yourself, note that it's the Coursier library doing the actual downloading and displaying the progress meter. (I had thought running sbt with COURSIER_PROGRESS=true might do the trick, but it didn't seem to help.)