Skip to content

Remove aliases created by buildx when installing by default#139

Merged
crazy-max merged 2 commits into
docker:masterfrom
hashhar:hashhar/cleanup-aliases
May 21, 2025
Merged

Remove aliases created by buildx when installing by default#139
crazy-max merged 2 commits into
docker:masterfrom
hashhar:hashhar/cleanup-aliases

Conversation

@hashhar

@hashhar hashhar commented Apr 25, 2022

Copy link
Copy Markdown
Contributor

If the action is configured to install buildx by default using the
input then docker buildx sets up docker build as an alias for buildx
making all docker build calls use the buildx builder instead of
traditional builders. The action didn't perform cleanup in this case to
uninstall the aliases which meant that any future workflows running on
same GitHub Actions runner would get the buildx builders even if it did
not explicitly request it.

This commit tracks if the aliases were installed and removes them during
post step of the action if so.

Fixes #125

@hashhar hashhar requested a review from crazy-max as a code owner April 25, 2022 07:04
@hashhar hashhar force-pushed the hashhar/cleanup-aliases branch 2 times, most recently from 3c6e8ed to fdd372a Compare April 25, 2022 07:07
@hashhar

hashhar commented Apr 26, 2022

Copy link
Copy Markdown
Contributor Author

Thanks for approving the CI run @tonistiigi. Looks green (kind of expected since no tests exist for the cleanup part and I couldn't figure out how to add one).

Let me know if there's something more you'd like me to do.

@crazy-max crazy-max left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the delay! Needs a rebase and adapt following changes that have been made recently, thanks!

Comment thread src/main.ts Outdated
Comment on lines 130 to 143
if (stateHelper.IsBuildxDefaultBuilder) {
core.startGroup('Uninstalling build aliased to buildx');
await exec
.getExecOutput('docker', ['buildx', 'uninstall'], {
ignoreReturnCode: true
})
.then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
core.warning(res.stderr.trim());
}
});
core.endGroup();
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since #204 and #213 we should have this in the post hook and handled through cleanup input.

@hashhar hashhar force-pushed the hashhar/cleanup-aliases branch from fdd372a to 640bfe6 Compare September 15, 2024 18:30
@hashhar

hashhar commented Sep 15, 2024

Copy link
Copy Markdown
Contributor Author

I've addressed the comments. PTAL @crazy-max. I eventually came back to this while cleaning up my open PRs.

hashhar and others added 2 commits May 21, 2025 11:59
If the action is configured to install buildx by default using the
input then docker buildx sets up docker build as an alias for buildx
making all docker build calls use the buildx builder instead of
traditional builders. The action didn't perform cleanup in this case to
uninstall the aliases which meant that any future workflows running on
same GitHub Actions runner would get the buildx builders even if it did
not explicitly request it.

This commit tracks if the aliases were installed and removes them during
post step of the action if so.

Signed-off-by: Ashhar Hasan <hashhar_dev@outlook.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max crazy-max force-pushed the hashhar/cleanup-aliases branch from 640bfe6 to f3204bb Compare May 21, 2025 10:01

@crazy-max crazy-max left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM thanks!

Pushed extra commit to update generated content.

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.

Cleanup aliases created by this action in post-step of action

2 participants