$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
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
https://github.com/hashicorp/vagrant/blob/d8fdc500b76c840cdeaa69869d0c000530b036b3/plugins/providers/docker/driver.rb#L127-L130 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
File content
.vagrant/machines/default/docker/docker_build_image
Debug output
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