Skip to content

ci: update docker version on codebuild #141697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ jobs:
with:
fetch-depth: 2

- name: update Docker version
if: matrix.codebuild
run: |
echo "updating Docker version"
src/ci/scripts/update-docker.sh

# Free up disk space on Linux by removing preinstalled components that
# we do not need. We do this to enable some of the less resource
# intensive jobs to run on free runners, which however also have
Expand Down
52 changes: 52 additions & 0 deletions src/ci/scripts/update-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
# Update Docker to the latest version on Ubuntu

set -euo pipefail

echo "previous docker version:"
sudo docker --version || true

echo "Remove old Docker packages"
for pkg in \
docker.io \
docker-compose \
docker-compose-v2 \
docker-doc \
podman-docker ;
do sudo apt-get remove -y $pkg || true; done

echo "Add Docker's official GPG key"
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

echo "Add the repository to Apt sources"
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

echo "Update the package database"
sudo apt-get update

echo "Install the latest version of Docker"
sudo apt-get install -y \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin

if ! sudo docker --version; then
echo "Docker installation failed"
exit 1
fi

echo "Docker updated successfully! New version:"
sudo docker --version
# # Start and enable Docker service
# sudo systemctl start docker
# sudo systemctl enable docker

# # Add current user to docker group (if not already)
# sudo usermod -aG docker $USER || true
Loading