hashicorp / vagrant

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

Enhancement Request: Add podman as a provider #12683

Open simao-silva opened 2 years ago

simao-silva commented 2 years ago

Is your feature request related to a problem? Please describe. Following the discussion in #12378, is podman supported or going to be supported as a provider?

Describe the solution you'd like Support of Podman as a provider

hussam-qasem commented 2 years ago

I look forward to having podman as a provider as well. Thank you!

jerrykan commented 1 year ago

It seems that the docker provider is just invoking docker commands in the background and not using the Docker daemon. Fortunately podman is a drop-in replacement for docker so a work-around is just to create a symbolic link for docker the points to the podman binary. An example of doing this on a Debian box would be:

sudo ln -s /usr/bin/podman /usr/local/bin/docker

However it would be nice if Vagrant was able to provide a podman provider that was an alias for the docker provider that just invoked the podman binary instead of the docker binary.

hussam-qasem commented 1 year ago

Fortunately podman is a drop-in replacement for docker so a work-around is just to create a symbolic link for docker the points to the podman binary. An example of doing this on a Debian box would be:

sudo ln -s /usr/bin/podman /usr/local/bin/docker

Depending on your distribution, you can install podman-docker instead:

$ dnf info podman-docker

Available Packages
Name         : podman-docker
...
Summary      : Emulate Docker CLI using podman
Description  : This package installs a script named docker that emulates the Docker CLI by
             : executes podman commands, it also creates links between all Docker CLI man
             : pages and podman.
Stromweld commented 1 year ago

I think this is a good feature request and wouldn't be too hard to add to the docker provider as an alias for podman, then variablize the docker commands with variable set based on provider.

jerrykan commented 1 year ago

After doing some more experimentation using Podman with Vagrant it seems there are incompatibilities with the networking side of things. When I try to use:

docker.vm.network :private_network, ip: "172.20.128.2"

I get the following error:

ERROR warden: Error occurred: undefined method `[]' for nil:NilClass

          config = network["IPAM"]["Config"]
                                  ^^^^^^^^^^

This seems to be because the output of docker network inspect is different than podman network inspect:

$ docker network inspect vagrant_network_172.20.128.0/24
[
    {
        "Name": "vagrant_network_172.20.128.0/24",
        "Id": "9f8e7e5fd1358cd217a64af1b915056067910c7558a019241b79f609f4596522",
        "Created": "2023-06-13T14:12:38.36957161Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.20.128.0/24"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {},
        "Options": {},
        "Labels": {}
    }
]
$ podman network inspect vagrant_network_172.20.128.0
[
     {
          "name": "vagrant_network_172.20.128.0",
          "id": "983ad7ff49e95a0b63c3262cb17be629cb60bb0ee69051e778fade038a70432e",
          "driver": "bridge",
          "network_interface": "podman1",
          "created": "2023-06-14T00:26:55.634945462+10:00",
          "subnets": [
               {
                    "subnet": "172.20.128.0/24",
                    "gateway": "172.20.128.1"
               }
          ],
          "ipv6_enabled": false,
          "internal": false,
          "dns_enabled": true,
          "ipam_options": {
               "driver": "host-local"
          }
     }
]

Note that Vagrant also creates networks with a / in the name which Podman doesn't support.

Looks like there might need to be a few more alterations made to the docker provider than just changing the binary that is invoked.