andrchi/vagrant-provider
Docker images that can be used as a provider for Vagrant as a Linux development environment.
109
These Docker images are designed to be used by Vagrant to set up a virtualized Linux development environment. In particular, they have proved useful for quickly setting up an Ubuntu x86_64 (amd64) environment on a Mac running Apple Silicon. This is made possible by the fact that Docker Desktop includes QEMU under the hood, which enables it to run a container whose architecture does not match the host's architecture.
The Dockerfiles that were used to build these images can be found at https://github.com/andrewchi/vagrant-docker-provider, a fork of the excellent work by John Rofrano in his vagrant-docker-provider.
Modifications from Rofrano's project are minimal:
Requirements:
Here is a sample Vagrantfile
for launching the Ubuntu x86_64 container on a Mac with Apple Silicon.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.hostname = "ubuntu-x86"
############################################################
# Provider for Docker on Intel or ARM (aarch64)
############################################################
config.vm.provider :docker do |docker, override|
override.vm.box = nil
docker.image = "andrchi/vagrant-provider:ubuntu-x86"
docker.remains_running = true
docker.has_ssh = true
docker.privileged = true
docker.volumes = ["/sys/fs/cgroup:/sys/fs/cgroup:rw"]
docker.create_args = ["--cgroupns=host"]
# Uncomment to force arm64 for testing images on Intel
# docker.create_args = ["--platform=linux/arm64", "--cgroupns=host"]
# Uncomment to force Intel for testing images on ARM / Apple Silicon
docker.create_args = ["--platform=linux/amd64", "--cgroupns=host"]
end
# Install Docker and pull an image
# config.vm.provision :docker do |d|
# d.pull_images "alpine:latest"
# end
end
Place the Vagrantfile
in a directory on the host (e.g., macOS). This directory will be shared with the container.
Once the Vagrantfile
is in place, cd
to that directory and use the following commands.
$ vagrant up # run the container (create if necessary)
$ vagrant ssh # login to the container
# guest's /vagrant directory == host's current working directory
$ vagrant halt # stop the container
$ vagrant destroy # delete the container
docker pull andrchi/vagrant-provider