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 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 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 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.

@crazy-max crazy-max merged commit 3f1544e into docker:master May 21, 2025
vbraun pushed a commit to sagemath/sage that referenced this pull request Jul 15, 2026
gh-42489: build(deps): bump docker/setup-buildx-action from 3 to 4
    
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-
buildx-action) from 3 to 4.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/docker/setup-buildx-
action/releases">docker/setup-buildx-action's releases</a>.</em></p>
<blockquote>
<h2>v4.0.0</h2>
<ul>
<li>Node 24 as default runtime (requires <a
href="https://github.com/actions/runner/releases/tag/v2.327.1">Actions
Runner v2.327.1</a> or later) by <a href="https://github.com/crazy-
max"><code>@​crazy-max</code></a> in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/483">docker/setup-buildx-action#483</a></li>
<li>Remove deprecated inputs/outputs by <a
href="https://github.com/crazy-max"><code>@​crazy-max</code></a> in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/464">docker/setup-buildx-action#464</a></li>
<li>Switch to ESM and update config/test wiring by <a
href="https://github.com/crazy-max"><code>@​crazy-max</code></a> in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/481">docker/setup-buildx-action#481</a></li>
<li>Bump <code>@​actions/core</code> from 1.11.1 to 3.0.0 in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/475">docker/setup-buildx-action#475</a></li>
<li>Bump <code>@​docker/actions-toolkit</code> from 0.63.0 to 0.79.0 in
<a href="https://redirect.github.com/docker/setup-buildx-
action/pull/482">docker/setup-buildx-action#482</a> <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/485">docker/setup-buildx-action#485</a></li>
<li>Bump js-yaml from 4.1.0 to 4.1.1 in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/452">docker/setup-buildx-action#452</a></li>
<li>Bump lodash from 4.17.21 to 4.17.23 in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/472">docker/setup-buildx-action#472</a></li>
<li>Bump minimatch from 3.1.2 to 3.1.5 in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/480">docker/setup-buildx-action#480</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/docker/setup-buildx-
action/compare/v3.12.0...v4.0.0">https://github.com/docker/setup-buildx-
action/compare/v3.12.0...v4.0.0</a></p>
<h2>v3.12.0</h2>
<ul>
<li>Deprecate <code>install</code> input by <a
href="https://github.com/crazy-max"><code>@​crazy-max</code></a> in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/455">docker/setup-buildx-action#455</a></li>
<li>Bump <code>@​docker/actions-toolkit</code> from 0.62.1 to 0.63.0 in
<a href="https://redirect.github.com/docker/setup-buildx-
action/pull/434">docker/setup-buildx-action#434</a></li>
<li>Bump brace-expansion from 1.1.11 to 1.1.12 in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/436">docker/setup-buildx-action#436</a></li>
<li>Bump form-data from 2.5.1 to 2.5.5 in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/432">docker/setup-buildx-action#432</a></li>
<li>Bump undici from 5.28.4 to 5.29.0 in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/435">docker/setup-buildx-action#435</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/docker/setup-buildx-
action/compare/v3.11.1...v3.12.0">https://github.com/docker/setup-
buildx-action/compare/v3.11.1...v3.12.0</a></p>
<h2>v3.11.1</h2>
<ul>
<li>Fix <code>keep-state</code> not being respected by <a
href="https://github.com/crazy-max"><code>@​crazy-max</code></a> in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/429">docker/setup-buildx-action#429</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/docker/setup-buildx-
action/compare/v3.11.0...v3.11.1">https://github.com/docker/setup-
buildx-action/compare/v3.11.0...v3.11.1</a></p>
<h2>v3.11.0</h2>
<ul>
<li>Keep BuildKit state support by <a href="https://github.com/crazy-
max"><code>@​crazy-max</code></a> in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/427">docker/setup-buildx-action#427</a></li>
<li>Remove aliases created when installing by default by <a
href="https://github.com/hashhar"><code>@​hashhar</code></a> in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/139">docker/setup-buildx-action#139</a></li>
<li>Bump <code>@​docker/actions-toolkit</code> from 0.56.0 to 0.62.1 in
<a href="https://redirect.github.com/docker/setup-buildx-
action/pull/422">docker/setup-buildx-action#422</a> <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/425">docker/setup-buildx-action#425</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/docker/setup-buildx-
action/compare/v3.10.0...v3.11.0">https://github.com/docker/setup-
buildx-action/compare/v3.10.0...v3.11.0</a></p>
<h2>v3.10.0</h2>
<ul>
<li>Bump <code>@​docker/actions-toolkit</code> from 0.54.0 to 0.56.0 in
<a href="https://redirect.github.com/docker/setup-buildx-
action/pull/408">docker/setup-buildx-action#408</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/docker/setup-buildx-
action/compare/v3.9.0...v3.10.0">https://github.com/docker/setup-buildx-
action/compare/v3.9.0...v3.10.0</a></p>
<h2>v3.9.0</h2>
<ul>
<li>Bump <code>@​docker/actions-toolkit</code> from 0.48.0 to 0.54.0 in
<a href="https://redirect.github.com/docker/setup-buildx-
action/pull/402">docker/setup-buildx-action#402</a> <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/404">docker/setup-buildx-action#404</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/docker/setup-buildx-
action/compare/v3.8.0...v3.9.0">https://github.com/docker/setup-buildx-
action/compare/v3.8.0...v3.9.0</a></p>
<h2>v3.8.0</h2>
<ul>
<li>Make cloud prefix optional to download buildx if driver is cloud by
<a href="https://github.com/crazy-max"><code>@​crazy-max</code></a> in
<a href="https://redirect.github.com/docker/setup-buildx-
action/pull/390">docker/setup-buildx-action#390</a></li>
<li>Bump <code>@​actions/core</code> from 1.10.1 to 1.11.1 in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/370">docker/setup-buildx-action#370</a></li>
<li>Bump <code>@​docker/actions-toolkit</code> from 0.39.0 to 0.48.0 in
<a href="https://redirect.github.com/docker/setup-buildx-
action/pull/389">docker/setup-buildx-action#389</a></li>
<li>Bump cross-spawn from 7.0.3 to 7.0.6 in <a
href="https://redirect.github.com/docker/setup-buildx-
action/pull/382">docker/setup-buildx-action#382</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/docker/setup-buildx-
action/compare/v3.7.1...v3.8.0">https://github.com/docker/setup-buildx-
action/compare/v3.7.1...v3.8.0</a></p>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="docker/setup-buildx-action@bb05f3
f5519dd87d3ba754cc423b652a5edd6d2c"><code>bb05f3f</code></a> Merge pull
request <a href="https://redirect.github.com/docker/setup-buildx-
action/issues/580">#580</a> from
docker/dependabot/npm_and_yarn/docker/actions-to...</li>
<li><a href="docker/setup-buildx-action@321c81
4cb51fbe4af8eca00249525cc0973ea66f"><code>321c814</code></a> [dependabot
skip] chore: update generated content</li>
<li><a href="docker/setup-buildx-action@b9a36e
f79ba42cfc611885a1e8c388fbf8b8cb3f"><code>b9a36ef</code></a>
build(deps): bump <code>@​docker/actions-toolkit</code> from 0.91.0 to
0.92.0</li>
<li><a href="docker/setup-buildx-action@ebeab2
41289497cd564ac98b3cfc9e64607bb276"><code>ebeab24</code></a> Merge pull
request <a href="https://redirect.github.com/docker/setup-buildx-
action/issues/570">#570</a> from
docker/dependabot/npm_and_yarn/undici-6.27.0</li>
<li><a href="docker/setup-buildx-action@5c7b8a
e78cec97a3215d4d86679b1d072eaa80cb"><code>5c7b8ae</code></a> [dependabot
skip] chore: update generated content</li>
<li><a href="docker/setup-buildx-action@037e61
8cd98e95e81525b15ff0e9c96f507e6a0e"><code>037e618</code></a>
build(deps): bump undici from 6.25.0 to 6.27.0</li>
<li><a href="docker/setup-buildx-action@66080e
5802281ec2e72b7f3108915643e702db85"><code>66080e5</code></a> Merge pull
request <a href="https://redirect.github.com/docker/setup-buildx-
action/issues/577">#577</a> from
docker/dependabot/npm_and_yarn/sigstore-4.1.1</li>
<li><a href="docker/setup-buildx-action@409aef
0aa3f48f0a742e7dec4e0e04ab19afe93c"><code>409aef0</code></a> Merge pull
request <a href="https://redirect.github.com/docker/setup-buildx-
action/issues/562">#562</a> from docker/dependabot/npm_and_yarn/js-
yaml-4.2.0</li>
<li><a href="docker/setup-buildx-action@49c6e4
2949280fa0d70fb327633591be54efbfb6"><code>49c6e42</code></a>
build(deps): bump sigstore from 4.1.0 to 4.1.1</li>
<li><a href="docker/setup-buildx-action@221127
3e8121ecf9ecb7d6c7c0fcd55526d530c7"><code>2211273</code></a> [dependabot
skip] chore: update generated content</li>
<li>Additional commits viewable in <a
href="https://github.com/docker/setup-buildx-
action/compare/v3...v4">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-
badges.githubapp.com/badges/compatibility_score?dependency-
name=docker/setup-buildx-action&package-manager=github_actions&previous-
version=3&new-version=4)](https://docs.github.com/en/github/managing-
security-vulnerabilities/about-dependabot-security-updates#about-
compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>
    
URL: #42489
Reported by: dependabot[bot]
Reviewer(s):
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