# CircleCI Docker Orb "Problem executing scripts APT::Update::Post-Invoke"

**URL:** <https://discuss.circleci.com/t/circleci-docker-orb-problem-executing-scripts-apt-post-invoke/49271>\
**Category:** Build Environment\
**Tags:** docker\
**Created:** [September 15, 2023, 8:00pm UTC](https://discuss.circleci.com/t/circleci-docker-orb-problem-executing-scripts-apt-post-invoke/49271 "2023-09-15T20:00:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksylvest](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/ksylvest/32/8215_2.png) [@ksylvest](https://discuss.circleci.com/u/ksylvest)\
**Post date:** [September 15, 2023, 8:00pm UTC](https://discuss.circleci.com/t/circleci-docker-orb-problem-executing-scripts-apt-post-invoke/49271/1 "2023-09-15T20:00:53Z")

</div>

I’m using the latest CircleCI Docker Orb to build a Dockerfile. Building the Dockerfile works fine locally, but on CI it gives:

```auto
Step 7/23 : RUN apt-get update -qq && apt-get install --no-install-recommends -y build-essential libpq-dev npm && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives
 ---> Running in 0ea16b3809b7
E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true'
E: Sub-process returned an error code
The command '/bin/sh -c rm -rf /var/lib/apt/lists/* && apt-get update -qq && apt-get install --no-install-recommends -y build-essential libpq-dev npm && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives' returned a non-zero code: 100

Exited with code exit status 100

```

The Dockerfile command is:

```auto
RUN \
  apt-get update -qq && \
  apt-get install --no-install-recommends -y build-essential libpq-dev npm && \
  rm -rf /var/lib/apt/lists/* /var/cache/apt/archives

```

I’ve tried running this with both new and existing projects to no avail. What might be causing this? The project is OS and here is a link to the PR:

> <https://github.com/ksylvest/personal/pull/2566/files>

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [September 15, 2023, 11:46pm UTC](https://discuss.circleci.com/t/circleci-docker-orb-problem-executing-scripts-apt-post-invoke/49271/2 "2023-09-15T23:46:36Z")

</div>

The first thing to do will be to split the 3 different commands you are executing in the single RUN command into 3 separate RUN commands so that you can tell which is throwing the error.

The fact that you have a error code, but no indication of what is causing the error means it is likely to be the “apt-get update -qq” command as “-qq” is telling it to be ‘very’ quiet. the apt-get manual states the following

```auto
-q, --quiet
    Quiet. Produces output suitable for logging, omitting progress indicators. 
More q's will produce more quiet up to a maximum of two. You can also 
use -q=# to set the quiet level, overriding the configuration file. Note that 
quiet level 2 implies -y, you should never use -qq without a no-action modifier 
such as -d, --print-uris or -s as APT may decided to do something you did not expect. 

```

Notice the bit about never using “-qq” without other modifiers.

---

<div class="post-metadata">

**Author:** ![ksylvest](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/ksylvest/32/8215_2.png) [@ksylvest](https://discuss.circleci.com/u/ksylvest)\
**Post date:** [September 16, 2023, 12:18am UTC](https://discuss.circleci.com/t/circleci-docker-orb-problem-executing-scripts-apt-post-invoke/49271/3 "2023-09-16T00:18:48Z")

</div>

Thanks, that’s helpful debugging - but I’m still very lost. I’ve simplified to a practically empty Dockerfile:

```auto
FROM ruby:3.2.2-slim
RUN apt-get update

```

This simple Dockerfile works locally - but doesn’t work on CircleCI.

```auto
+ docker build --file=./Dockerfile --tag=docker.io/ ******** /personal:... .
Sending build context to Docker daemon 126.2MB
Step 1/2 : FROM ruby:3.2.2-slim
3.2.2-slim: Pulling from library/ruby
360eba32fa65: Pull complete 
f4acd8d05bbc: Pull complete 
28fab83683a6: Pull complete 
b1b52a1bc24f: Pull complete 
7253d00afd18: Pull complete 
Digest: sha256:...
Status: Downloaded newer image for ruby:3.2.2-slim
 ---> c2ac71ef3cf6
Step 2/2 : RUN apt-get update
 ---> Running in 5f9011810254
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:2 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB]
Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:4 http://deb.debian.org/debian bookworm/main amd64 Packages [8906 kB]
Get:5 http://deb.debian.org/debian bookworm-updates/main amd64 Packages [6432 B]
Get:6 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages [62.1 kB]
Fetched 9226 kB in 1s (7229 kB/s)
Reading package lists...
E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true'
E: Sub-process returned an error code
The command '/bin/sh -c apt-get update' returned a non-zero code: 100

Exited with code exit status 100

```

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [September 16, 2023, 10:15am UTC](https://discuss.circleci.com/t/circleci-docker-orb-problem-executing-scripts-apt-post-invoke/49271/4 "2023-09-16T10:15:15Z")

</div>

As you have got the issue down to the updating of the ruby:3.2.2-slim image you can try

- using a different image as there is a range of 3.2.2 options

- post the issue you are seeing to the issue board for the image here

---

<div class="post-metadata">

**Author:** ![ksylvest](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/ksylvest/32/8215_2.png) [@ksylvest](https://discuss.circleci.com/u/ksylvest)\
**Post date:** [September 16, 2023, 11:24pm UTC](https://discuss.circleci.com/t/circleci-docker-orb-problem-executing-scripts-apt-post-invoke/49271/5 "2023-09-16T23:24:18Z")

</div>

I gave this a try with a base debian image and am seeing the exact same issue:

```auto
FROM debian:bookworm-slim
RUN apt-get update

```

```auto
...
Reading package lists...
E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true'
E: Sub-process returned an error code
The command '/bin/sh -c apt-get update' returned a non-zero code: 100

```

Again this works perfectly with my local Docker. This appears to be an issue with CircleCI. Is that your opinion also?

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [September 16, 2023, 11:39pm UTC](https://discuss.circleci.com/t/circleci-docker-orb-problem-executing-scripts-apt-post-invoke/49271/6 "2023-09-16T23:39:21Z")

</div>

Yes, it seems to be an issue with the environment that CircleCI is providing to execute the docker container, but I have no real idea what it could be beyond the exact version of the docker tools being used.

What executor are you defining for your environment? At the moment all I can do is ask for info that may be helpful to staff members when they are next available.

---

<div class="post-metadata">

**Author:** ![ksylvest](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/ksylvest/32/8215_2.png) [@ksylvest](https://discuss.circleci.com/u/ksylvest)\
**Post date:** [September 17, 2023, 12:09am UTC](https://discuss.circleci.com/t/circleci-docker-orb-problem-executing-scripts-apt-post-invoke/49271/7 "2023-09-17T00:09:30Z")

</div>

> [@rit1010](#):
>
> What executor are you defining for your environment? At the moment all I can do is ask for info that may be helpful to staff members when they are next available.

Good call on the executor. Since I was using the orb I had not bothered looking into it. It appears to be using an image this is fairly out of date:

```auto
machine-agent version 1.0.58497-1b21ea3b (image: "ubuntu-2004:202107-02", public ip: "44.202.135.1", provider: "EC2")

```

This change to my `.circleci/config.yml` solves:

**Before (Fails)**

```yaml
workflows:
  version: 2.1
  build:
    jobs:
      - docker/publish:
          image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
          tag: << pipeline.git.revision >>

```

**After (Works)**

```auto
workflows:
  version: 2.1
  build:
    jobs:
      - docker/publish:
          executor:
            name: docker/machine
            image: ubuntu-2204:2023.02.1
          image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
          tag: << pipeline.git.revision >>

```

I’ve opened an issue:

> <https://github.com/CircleCI-Public/docker-orb/issues/184>
>
> \### Orb version
> 
> v2.2.0
> 
> \### What happened
> 
> With the following Dockerfile:…
> 
> \`\`\`
> FROM debian:bookworm-slim
> RUN apt-get update
> \`\`\`
> 
> The following error is logged:
> 
> \`\`\`
> + docker build --file=./Dockerfile --tag=docker.io/\*\*\*\*\*\*\*\*/... .
> Sending build context to Docker daemon 126.2MB
> Step 1/2 : FROM debian:bookworm-slim
> bookworm-slim: Pulling from library/debian
> 360eba32fa65: Pull complete 
> Digest: sha256:...
> Status: Downloaded newer image for debian:bookworm-slim
> ---\> 8cd9a4094900
> Step 2/2 : RUN apt-get update
> ---\> Running in 476a2d216a19
> Get:1 http://deb.debian.org/debian bookworm InRelease \[151 kB\]
> Get:2 http://deb.debian.org/debian bookworm-updates InRelease \[52.1 kB\]
> Get:3 http://deb.debian.org/debian-security bookworm-security InRelease \[48.0 kB\]
> Get:4 http://deb.debian.org/debian bookworm/main amd64 Packages \[8906 kB\]
> Get:5 http://deb.debian.org/debian bookworm-updates/main amd64 Packages \[6432 B\]
> Get:6 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages \[62.1 kB\]
> Fetched 9226 kB in 1s (9459 kB/s)
> Reading package lists...
> E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/\*.deb /var/cache/apt/archives/partial/\*.deb /var/cache/apt/\*.bin || true'
> E: Sub-process returned an error code
> The command '/bin/sh -c apt-get update' returned a non-zero code: 100
> 
> Exited with code exit status 100
> \`\`\`
> 
> For further detail see: https://discuss.circleci.com/t/circleci-docker-orb-problem-executing-scripts-apt-post-invoke/49271/7
> 
> \### Expected behavior
> 
> A docker image is built.

With the PR to fix:

> <https://github.com/CircleCI-Public/docker-orb/pull/183>
>
> \### Checklist
> 
> \- \[x\] All new jobs, commands, executors, parameters have descri…ptions
> \- \[x\] Examples have been added for any significant new features
> \- \[x\] README has been updated, if necessary
> 
> \### Motivation
> 
> Attempting to fix basic Dockerfile failing to build:
> 
> \`\`\`
> FROM debian:bookworm-slim
> RUN apt-get update
> \`\`\`
> 
> Further details see: https://github.com/CircleCI-Public/docker-orb/issues/184 / https://discuss.circleci.com/t/circleci-docker-orb-problem-executing-scripts-apt-post-invoke/49271/6
> 
> \### Description
> 
> Bumping versions of underlying executor for build job.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [September 24, 2023, 12:09am UTC](https://discuss.circleci.com/t/circleci-docker-orb-problem-executing-scripts-apt-post-invoke/49271/8 "2023-09-24T00:09:39Z")

</div>

Closed on September 24, 2023, 12:09am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
