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

Open
eszense opened this issue Apr 22, 2024 · 0 comments
Open

Docker rebuild existing image due to incorrect check #13384

eszense opened this issue Apr 22, 2024 · 0 comments

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant