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

Docker rebuild existing image due to incorrect check #13384

Closed
eszense opened this issue Apr 22, 2024 · 1 comment · Fixed by #13489
Closed

Docker rebuild existing image due to incorrect check #13384

eszense opened this issue Apr 22, 2024 · 1 comment · Fixed by #13489

Comments

@eszense
Copy link

eszense commented Apr 22, 2024

Vagrant is always rebuilding existing image on my machine.

Likely this is caused by a bug here. Which attempts search for an existing image ID from the command docker images -q

def image?(id)
result = execute('docker', 'images', '-q').to_s
result =~ /^#{Regexp.escape(id)}$/
end

However, docker images -q only outputs the short (truncated) image ID without the --no-trunc argument, hence there was no match for the full image ID cached on .vagrant/machines/default/docker/docker_build_image

Docker output

$docker image ls -q
302d1cb135c3
...

$docker image ls -q --no-trunc
sha256:302d1cb135c325ea41b8e1a748af44119be535ee88431274a2d4d8265b45ae0d
...

File content

.vagrant/machines/default/docker/docker_build_image

302d1cb135c325ea41b8e1a748af44119be535ee88431274a2d4d8265b45ae0d

Debug output

$vagrant up
Bringing machine 'default' up with 'docker' provider...
==> default: Creating and configuring docker networks...
==> default: Build image no longer exists. Rebuilding...
==> default: Building the container from the named Dockerfile: Dockerfile...

Expected behavior

Skip rebuild when image already exists

Vagrant version

Vagrant 2.4.1

Host operating system

macOS Sonoma ARM64
Docker version 24.0.6

Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.provider "docker" do |d|
    d.build_dir = "."
    d.dockerfile = "Dockerfile"
    d.remains_running = false
  end
end
@allisonlarson
Copy link
Member

Thanks for making this bug report as well! The issue has been fixed, and the fix will be available in the next release.

Cheers!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants