<p>In my case, the solution was to remove the distro provided docker (which I didn't have -- this is just for safety),</p>
<pre><code>$ for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
</code></pre>
<p>Which should do nothing, and didn't for me but that's fine. Then you need to reinstall <code>docker-ce</code>,</p>
<pre class="lang-shell prettyprint-override"><code>apt-get --reinstall install docker-ce
</code></pre>
<p>In my case, that didn't work either, because the distro upgrade from one version of Ubuntu to another disabled the <code>docker-ce</code> repo, so I had to re-add that, I just re-ran the commands Docker provides,</p>
<pre class="lang-shell prettyprint-override"><code># Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  &quot;deb [arch=&quot;$(dpkg --print-architecture)&quot; signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  &quot;$(. /etc/os-release &amp;&amp; echo &quot;$VERSION_CODENAME&quot;)&quot; stable&quot; | \
  sudo tee /etc/apt/sources.list.d/docker.list &gt; /dev/null
sudo apt-get update
</code></pre>
<p>Then I ran,</p>
<pre class="lang-shell prettyprint-override"><code>apt-get --reinstall install docker-ce
</code></pre>
<p>And it worked!</p>

CC BY-SA 4.0
2023-09-13T01:21:10.647Z
2023-09-13T01:21:10.647Z
Evan Carroll
<p>I ran the command <code>sudo rm -rf ~/.local/share/containers/</code> and now I'm getting,</p>
<pre><code>ERROR: BuildKit is enabled but the buildx component is missing or broken.
       Install the buildx component to build images with BuildKit:
       https://docs.docker.com/go/buildx/
</code></pre>
<p>When I try to run <code>docker build</code> how can I resolve this error?</p>

<docker><ubuntu>
Docker on Ubuntu, getting ERROR: BuildKit is enabled but the buildx component is missing or broken. Install the buildx component
Evan Carroll
# Docker on Ubuntu, getting ERROR: BuildKit is enabled but the buildx component is missing or broken. Install the buildx component

(Asked by: username_0 on 2023-09-13)

I ran the command sudo rm -rf ~/.local/share/containers/ and now I'm getting,
ERROR: BuildKit is enabled but the buildx component is missing or broken.
       Install the buildx component to build images with BuildKit:
       https://docs.docker.com/go/buildx/

When I try to run docker build how can I resolve this error?

**Tags:** docker, ubuntu


---

## 1 answers

### Answer by username_0 on 2023-09-13. Score: 0 | Accepted answer

In my case, the solution was to remove the distro provided docker (which I didn't have -- this is just for safety),
$ for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done

Which should do nothing, and didn't for me but that's fine. Then you need to reinstall docker-ce,
apt-get --reinstall install docker-ce

In my case, that didn't work either, because the distro upgrade from one version of Ubuntu to another disabled the docker-ce repo, so I had to re-add that, I just re-ran the commands Docker provides,
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

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

Then I ran,
apt-get --reinstall install docker-ce

And it worked!


---

