Skip to content

Instantly share code, notes, and snippets.

@PramodBisht
Forked from Cobra16319/Read.md
Created February 29, 2024 12:42
Show Gist options
  • Save PramodBisht/1aaa9800e4834feb5e9b9c11bf36b356 to your computer and use it in GitHub Desktop.
Save PramodBisht/1aaa9800e4834feb5e9b9c11bf36b356 to your computer and use it in GitHub Desktop.
Run Vagrant on an M1 Mac Book with Docker

Here is a sample multi-provider Vagrantfile that can use either VirtualBox or Docker as a provider with vagrant:

$touch Vagrantfile

#Copy and paste Vagrantfile into newly created file

$vagrant up --provider=docker

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.hostname = "ubuntu"
# Provider for VirtualBox
config.vm.provider :virtualbox do |vb|
vb.memory = "1024"
vb.cpus = 2
end
# Provider for Docker
config.vm.provider :docker do |docker, override|
override.vm.box = nil
docker.image = "rofrano/vagrant-provider:ubuntu"
docker.remains_running = true
docker.has_ssh = true
docker.privileged = true
docker.volumes = ["/sys/fs/cgroup:/sys/fs/cgroup:ro"]
end
# Provision Docker Engine and pull down PostgreSQL
config.vm.provision :docker do |d|
d.pull_images "postgres:alpine"
d.run "postgres:alpine",
args: "-d -p 5432:5432 -e POSTGRES_PASSWORD=postgres"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment