Skip to content
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

install docker-buildx-plugin on >= 22.06 (test channel only currently) #295

Merged
merged 1 commit into from
Jun 7, 2022

Conversation

thaJeztah
Copy link
Member

The buildx plugin has moved to a separate package for the 22.06 release.
We're currently doing test-builds on staging, so only try to install
this when using both the "test" channel and the staging domain.

@thaJeztah thaJeztah force-pushed the add_buildx_package branch from 3a96765 to e1b3592 Compare June 3, 2022 20:54
@@ -444,6 +444,10 @@ do_install() {
# also install the latest version of the "docker scan" cli-plugin (only supported on x86 currently)
pkgs="$pkgs docker-scan-plugin"
fi
# TODO(thaJeztah) remove the $CHANNEL check once 22.06 and docker-buildx-plugin is published to the "stable" channel
if [ "$CHANNEL" = "test" ] && version_gte "22.06"; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version wouldn't ever be greater than 22.06 in the stable channel yet anyhow, right? So this is probably safe to remove the CHANNEL test from and merge? 🙏

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So.. lol, it was late when I originally wrote this patch, and I wasn't sure what version_gte did if no version was specified explicitly (as "no version" means "install latest"), so I wanted to safeguard against that (Then decided not to take the risk either way, and leave it in draft until later)

I should have a look at that, and if that's not the case, I can remove it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick try to see what happens if we remove the $CHANNEL check, but it's indeed written with the assumption that "if no version is specified, then version_gte is always true";

curl -fsSL https://raw.githubusercontent.com/thaJeztah/docker-install/add_buildx_package/install.sh -o get-docker.sh

sed -i 's/\[ "$CHANNEL" = "test" ] && //g' ./get-docker.sh 
sh ./get-docker.sh

# Executing docker install script, commit:
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c mkdir -p /etc/apt/keyrings && chmod -R 0755 /etc/apt/keyrings
+ sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
+ sh -c chmod a+r /etc/apt/keyrings/docker.gpg
+ sh -c echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable" > /etc/apt/sources.list.d/docker.list
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-scan-plugin docker-buildx-plugin >/dev/null
E: Unable to locate package docker-buildx-plugin

We could change that to have the script actually resolve the latest version, so get it from, e.g.;

apt-cache policy 'docker-ce' | grep 'Candidate:' | cut -d' ' -f4
5:20.10.17~3-0~ubuntu-jammy

But I guess that would make the script a bit too complicated, just for this purpose.

The buildx plugin has moved to a separate package for the 22.06 release.
We're currently doing test-builds on staging, so only try to install
this when using both the "test" channel and the staging domain.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the add_buildx_package branch from e1b3592 to df6b692 Compare June 7, 2022 01:39
@thaJeztah
Copy link
Member Author

As docker buildx is now in a separate package, doing a apt-get update && apt-get upgrade will not automatically update docker-ce-cli (so we may have to update some instructions for upgrading docker);

The following packages have been kept back:
  docker-ce-cli
The following packages will be upgraded:
  docker-ce docker-ce-rootless-extras docker-compose-plugin dpkg libpcre3 libudev1
6 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 27.9 MB of archives.
After this operation, 10.1 MB disk space will be freed.

Some details can be found in https://askubuntu.com/a/602

If the dependencies have changed on one of the packages you have installed so that a new package must be installed to perform the upgrade then that will be listed as "kept-back".

However, explicitly installing all packages (as we describe in our install docs, and as this script does) will avoid that situation.

Giving this a try (using the updated get.docker.com script from this PR)

First, install docker 20.10.17

curl -fsSL https://raw.githubusercontent.com/thaJeztah/docker-install/add_buildx_package/install.sh | CHANNEL=test VERSION=20.10.17 sh

docker version
Client: Docker Engine - Community
 Version:           20.10.17
 ...

Server: Docker Engine - Community
 Engine:
  Version:          20.10.17
  ...

Check the buildx version (v0.8.2-docker is the version bundled in docker-ce-cli)

docker buildx version
github.com/docker/buildx v0.8.2-docker 6224def4dd2c3d347eee19db595348c50d7cb491

And the list of packages installed

dpkg -l | grep docker
ii  docker-ce                       5:20.10.17~3-0~ubuntu-jammy             amd64        Docker: the open-source application container engine
ii  docker-ce-cli                   5:20.10.17~3-0~ubuntu-jammy             amd64        Docker CLI: the open-source application container engine
ii  docker-ce-rootless-extras       5:20.10.17~3-0~ubuntu-jammy             amd64        Rootless support for Docker.
ii  docker-compose-plugin           2.6.0~ubuntu-jammy                      amd64        Docker Compose (V2) plugin for the Docker CLI.
ii  docker-scan-plugin              0.17.0~ubuntu-jammy                     amd64        Docker scan cli plugin.

Then, upgrade to 22.06 (removing VERSION=20.10.17)

curl -fsSL https://raw.githubusercontent.com/thaJeztah/docker-install/add_buildx_package/install.sh | CHANNEL=test sh

docker version
Client: Docker Engine - Community
 Version:           22.06.0-beta.0
 ...

Server: Docker Engine - Community
 Engine:
  Version:          22.06.0-beta.0
  ...

Check the buildx version (v0.8.2 without the -docker suffix is the version from the separate package)

docker buildx version
github.com/docker/buildx v0.8.2

And the list of packages installed

dpkg -l | grep docker
ii  docker-buildx-plugin            0.8.2~ubuntu-jammy                      amd64        Docker Buildx cli plugin.
ii  docker-ce                       5:22.06.0~beta.0-0~ubuntu.22.04.0~jammy amd64        Docker: the open-source application container engine
ii  docker-ce-cli                   5:22.06.0~beta.0-0~ubuntu.22.04.0~jammy amd64        Docker CLI: the open-source application container engine
ii  docker-ce-rootless-extras       5:22.06.0~beta.0-0~ubuntu.22.04.0~jammy amd64        Rootless support for Docker.
ii  docker-compose-plugin           2.6.0~ubuntu-jammy                      amd64        Docker Compose (V2) plugin for the Docker CLI.
ii  docker-scan-plugin              0.17.0~ubuntu-jammy                     amd64        Docker scan cli plugin.

@thaJeztah
Copy link
Member Author

Did a quick check if version matching still works after we changed the version format for the packages in docker/docker-ce-packaging#701.

Tried to see if specifying 22.06.0-beta.0 (using a hyphen (-) before the beta, which doesn't match deb package versions (which require a tilde (~)), but it looks like that's already handled;

curl -fsSL https://raw.githubusercontent.com/thaJeztah/docker-install/add_buildx_package/install.sh | CHANNEL=test VERSION=22.06.0-beta.0 sh
# Executing docker install script, commit:
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c mkdir -p /etc/apt/keyrings && chmod -R 0755 /etc/apt/keyrings
+ sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
+ sh -c chmod a+r /etc/apt/keyrings/docker.gpg
+ sh -c echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy test" > /etc/apt/sources.list.d/docker.list
+ sh -c apt-get update -qq >/dev/null
INFO: Searching repository for VERSION '22.06.0-beta.0'
INFO: apt-cache madison 'docker-ce' | grep '22.06.0.*beta.0.*-0~ubuntu' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3
INFO: apt-cache madison 'docker-ce-cli' | grep '22.06.0.*beta.0.*-0~ubuntu' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends docker-ce=5:22.06.0~beta.0-0~ubuntu.22.04.0~jammy docker-ce-cli=5:22.06.0~beta.0-0~ubuntu.22.04.0~jammy containerd.io docker-compose-plugin docker-scan-plugin docker-buildx-plugin >/dev/null
+ version_gte 20.10
+ [ -z 22.06.0-beta.0 ]
+ eval calver_compare 22.06.0-beta.0 20.10
+ calver_compare 22.06.0-beta.0 20.10
+ set +x
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce-rootless-extras=5:22.06.0~beta.0-0~ubuntu.22.04.0~jammy >/dev/null
+ sh -c docker version
Client: Docker Engine - Community
 Version:           22.06.0-beta.0

Also tried specifying a partial version (22.06), and that works fine as well;

curl -fsSL https://raw.githubusercontent.com/thaJeztah/docker-install/add_buildx_package/install.sh | CHANNEL=test VERSION=22.06 sh

+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c mkdir -p /etc/apt/keyrings && chmod -R 0755 /etc/apt/keyrings
+ sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
+ sh -c chmod a+r /etc/apt/keyrings/docker.gpg
+ sh -c echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy test" > /etc/apt/sources.list.d/docker.list
+ sh -c apt-get update -qq >/dev/null
INFO: Searching repository for VERSION '22.06'
INFO: apt-cache madison 'docker-ce' | grep '22.06.*-0~ubuntu' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3
INFO: apt-cache madison 'docker-ce-cli' | grep '22.06.*-0~ubuntu' | head -1 | awk '{$1=$1};1' | cut -d' ' -f 3
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends docker-ce=5:22.06.0~beta.0-0~ubuntu.22.04.0~jammy docker-ce-cli=5:22.06.0~beta.0-0~ubuntu.22.04.0~jammy containerd.io docker-compose-plugin docker-scan-plugin docker-buildx-plugin >/dev/null
+ version_gte 20.10
+ [ -z 22.06 ]
+ eval calver_compare 22.06 20.10
+ calver_compare 22.06 20.10
+ set +x
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce-rootless-extras=5:22.06.0~beta.0-0~ubuntu.22.04.0~jammy >/dev/null
+ sh -c docker version
Client: Docker Engine - Community
 Version:           22.06.0-beta.0

@thaJeztah thaJeztah marked this pull request as ready for review June 7, 2022 09:46
@thaJeztah
Copy link
Member Author

Alright; based on the testing above, this looks to be working as expected; let me bring this one in.

@thaJeztah thaJeztah merged commit b2e29ef into docker:master Jun 7, 2022
@thaJeztah thaJeztah deleted the add_buildx_package branch June 7, 2022 09:51
@thaJeztah
Copy link
Member Author

Scripts at https://get.docker.com and https://test.docker.com have been updated;

curl -fsSL https://get.docker.com | sudo CHANNEL=test sh

or the test.docker.com script (automatically sets channel to test);

curl -fsSL https://test.docker.com | sudo sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants