Skills2026年4月13日·1 分钟阅读

Vagrant — Portable Development Environments Made Simple

Vagrant is a tool for building and managing portable development environments. Define your environment in a Vagrantfile, run vagrant up, and get a fully configured virtual machine — ensuring every developer works in an identical environment.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
step-1.md
先审查命令
npx -y tokrepo@latest install 69552a5c-3702-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

TL;DR
Vagrant lets teams define full virtual machines in a Vagrantfile and spin them up with one command.
§01

What it is

Vagrant is an open-source tool by HashiCorp for building and managing portable development environments. You describe your environment in a declarative Vagrantfile, run vagrant up, and get a fully configured virtual machine regardless of your host OS.

Vagrant is best suited for teams that need OS-level isolation beyond what containers provide. If you need to test on different kernels, run full system stacks, or develop software requiring kernel-level access, Vagrant remains the right choice.

§02

How it saves time or tokens

Vagrant eliminates manual environment setup. Instead of writing a wiki page with 30 steps that each developer interprets differently, you commit a single Vagrantfile. New team members run vagrant up and get an identical environment in minutes. Provisioners (shell scripts, Ansible, Chef, Puppet) automate every configuration step, removing human error from the loop.

§03

How to use

  1. Install Vagrant and a provider (VirtualBox is the default free option)
  2. Initialize a project with a base box:
mkdir my-project && cd my-project
vagrant init ubuntu/jammy64
  1. Start and connect to the VM:
vagrant up
vagrant ssh
  1. Customize the Vagrantfile for your stack (forward ports, sync folders, run provisioners)
§04

Example

# Vagrantfile
Vagrant.configure('2') do |config|
  config.vm.box = 'ubuntu/jammy64'
  config.vm.network 'forwarded_port', guest: 3000, host: 3000
  config.vm.synced_folder '.', '/vagrant'

  config.vm.provision 'shell', inline: <<-SHELL
    apt-get update
    apt-get install -y nodejs npm
    cd /vagrant && npm install
  SHELL
end

Run vagrant up and your Node.js environment is ready with port 3000 forwarded to your host.

§05

Related on TokRepo

§06

Common pitfalls

  • Using VirtualBox on Apple Silicon Macs without switching to a compatible provider like VMware or Parallels
  • Forgetting to add the Vagrantfile to version control, defeating the purpose of reproducible environments
  • Over-provisioning VMs with too much RAM or CPU when the workload does not require it

常见问题

How does Vagrant differ from Docker?+

Vagrant manages full virtual machines with their own kernel, while Docker runs containers sharing the host kernel. Use Vagrant when you need OS-level isolation, kernel testing, or Windows/Linux cross-platform development. Use Docker when you need lightweight process isolation for microservices.

Which providers does Vagrant support?+

Vagrant supports VirtualBox (free, default), VMware (paid plugin), Hyper-V (Windows), Parallels (macOS), and cloud providers like AWS and Google Cloud. You choose a provider based on your host OS and performance requirements.

Can Vagrant work alongside Docker?+

Yes. Vagrant can provision a VM that runs Docker inside it, or you can use the Docker provider to let Vagrant manage containers directly. This is useful for teams that want Vagrant's workflow but Docker's runtime.

Is Vagrant still relevant in 2026 with containers everywhere?+

Vagrant remains relevant for full-OS testing, multi-OS development, and scenarios where kernel-level access matters. It is not a competitor to Docker but serves a different use case: full machine virtualization with reproducible configuration.

How do I share a Vagrant box with my team?+

Commit the Vagrantfile to your repository. Each developer runs vagrant up to build the same environment. For custom base boxes, host them on Vagrant Cloud or an internal HTTP server and reference them in the Vagrantfile.

引用来源 (3)

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产