hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.05k stars 4.42k forks source link

vagrant docker provider will not run provisioner #13236

Closed larsks closed 1 year ago

larsks commented 1 year ago

Debug output

vagrant-up.log

Expected behavior

Given the following Vagrantfile:

$script = <<-SCRIPT
#!/bin/sh
apk update
apk add python3
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.provider "docker" do |d|
    d.image = "docker.io/alpine:latest"
    d.cmd = ["sleep", "inf"]
    d.remains_running = true
  end

  config.vm.provision "shell", inline: $script
end

I expect that running vagrant up will:

  1. Create a Docker container (named vagrant_default_...)
  2. Run the given shell script inside the container

Actual behavior

Vagrant creates a container:

CONTAINER ID   IMAGE                  COMMAND                  CREATED          STATUS          PORTS                                                                                     NAMES
208b807368ad   alpine:latest          "sleep inf"              33 seconds ago   Up 32 seconds                                                                                             vagrant_default_1690081570

But does not run the provisioner. The logs (see the earlier link) include:

INFO has_provisioner: Skipping running provisioner no name, type: shell

That seems to indicate the provisioner was explicitly skipped, but I'm not sure why. Running vagrant provision does not run the provisioner either.

Reproduction information

Vagrant version

Vagrant 2.2.19

Host operating system

Fedora 38

Guest operating system

N/A

Steps to reproduce

(See above)

Vagrantfile

(See above)

larsks commented 1 year ago

I did not realize that vagrant requires ssh to be installed in an container. I thought it would use docker exec for provisioning.