1

I have a multi-stage, multi-arch Docker build process using Docker's debian:latest image and the Chromium/Firefox packages from Debian Sid. Sometimes when building the images, something fails with the following error:

Errors were encountered while processing: #0 221.2 system-config-printer-common #0 221.2 system-config-printer #0 221.3 E: Sub-process /usr/bin/dpkg returned an error code (1) 

If I rerun the build, it then works. This suggests that it's not necessarily a broken package. Because this is an automated build, I'm wondering if there is a way to "catch" these errors and retry whatever step failed automatically?

1 Answer 1

2

If you’re sure the command will eventually succeed, you can retry it with until. In your container build:

until apt install package; do :; done 

or if you’d rather re-run the whole build:

until docker build …; do :; done 

These commands can be adapted to retry up to a pre-determined number of times.

In your case however, unless you really do need system-config-printer (which would be surprising in a container image), you’d be better off avoiding its installation altogether — start by trying apt install --no-install-recommends.

1
  • I'm going to try this out. What you did in your other answer with the "try this only X times" logic is exactly what I'm looking for. These failures are happening on a CircleCI runner. When the job fails, I can select "rerun from failed" in CircleCI and the build then succeeds, so I'm hoping if I can rerun everything automatically that it won't need as much manual intervention. I'll update what happens here. Thank you. Commented Apr 22, 2023 at 7:17

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.