"apt-get update" fails on images based on Ubuntu

Hi,

Over the past few days “apt-get update” fails on images based on Ubuntu with errors like these:

W: https://download.docker.com/linux/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
E: Problem executing scripts APT::Update::Post-Invoke-Success '/usr/bin/test -e /usr/share/dbus-1/system-services/org.freedesktop.PackageKit.service && /usr/bin/test -S /var/run/dbus/system_bus_socket && /usr/bin/gdbus call --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit --timeout 4 --method org.freedesktop.PackageKit.StateHasChanged cache-update > /dev/null; /bin/echo > /dev/null'
E: Sub-process returned an error code
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

Please note that this happened on already deployed solutions. I tried to switch to an LTS version (e.g. ubuntu:22.04) but no difference.

Is there a nice solution which can be included in a circleci config.yml (i.e. not editing files manually etc)

Thanks

It is hard to tell from what you have posted, but one thing worth doing is checking the version of docker you have running at the time you get these errors. 22.04 ships with a very old version of docker as standard. This allows them to maintain capability between their distros and I think Redhat but makes usability a problem.

I have no idea if you use ansible, but below is the script I use to upgrade docker on my 22.04 deployments

It removes all the default docker-related packages, adds the required info for the Docker Repository and then installs all the packages from the repo.

- name: Remove the old docker packages deployed in Ubuntu
  apt:
    pkg:
      - docker
      - docker-engine
      - docker.io
      - containerd
      - docker-compose-plugin
    state: absent
    update_cache: true
  register: apt
- debug: msg={{ apt.stdout.split('\n')[:-1] }}
  when: aptout.stdout_lines is defined


- name: Add Docker GPG apt Key
  apt_key:
    url: https://download.docker.com/linux/ubuntu/gpg
    state: present


- name: Add Docker Repository
  apt_repository:
    repo: deb https://download.docker.com/linux/ubuntu jammy stable
    state: present


- name: Update apt and install docker-ce
  apt:
    pkg:
      - docker-ce
      - docker-ce-cli
      - containerd.io
      - docker-compose-plugin
    state: latest
    update_cache: true
  register: apt
#- debug: msg={{ apt.stdout.split('\n')[:-1] }}
#  when: aptout.stdout_lines is defined


- name: Install Docker Module for Python
  pip:
    name: docker

Hey,

Thank you for the response.
That was actually a great suggestion.

I specified a docker version before running “apt-get update” and it now works:

steps:
      - setup_remote_docker:
          version: 20.10.14

      - run: apt-get update

I’m not sure if this is the best way to do it. But it works. Thank you

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