Vagrant
lastmod 2025-12-23created 2014-12-1025 edits
Vagrant is free and open-source software for creating and configuring virtual development environments. It can be seen as a wrapper around virtualization software such as VirtualBox, KVM, VMware and around configuration management software such as Chef, Salt or Puppet.
Categories
Install
On Windows, use winget:
Looking at the printed log, it ends up downloading the msi installer from the homepage anyway
찾음 Vagrant [Hashicorp.Vagrant] 버전 2.4.9
이 응용 프로그램의 라이선스는 그 소유자가 사용자에게 부여했습니다.
Microsoft는 타사 패키지에 대한 책임을 지지 않고 라이선스를 부여하지도 않습니다.
다운로드 중 https://releases.hashicorp.com/vagrant/2.4.9/vagrant_2.4.9_windows_amd64.msi
██████████████████████████████ 236 MB / 236 MB
설치 관리자 해시를 확인했습니다.
패키지 설치를 시작하는 중...
설치 성공
On Ubuntu:
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install vagrant
Usage
- Create a Vagrantfile
-
vagrant init
- Provision the VM (start the VM if it already exists)
-
vagrant up
- Connect to the VM
-
vagrant ssh,vagrant ssh k8s-control
- Check VM status
-
vagrant status
- Stop the VM (graceful shutdown)
-
vagrant halt
- Force stop the VM
-
vagrant halt --force
- Suspend the VM (save state)
-
vagrant suspend
- Delete the VM
-
vagrant destroy
- Check VM status
-
vagrant status
- Check status of all VMs
-
vagrant global-status
- Check the VM's SSH connection settings
-
vagrant ssh-config
Connecting as a different account
Checking the SSH connection settings with vagrant ssh-config prints something like this:
Host default
HostName 127.0.0.1
User zer0
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile C:/Users/zer0/Project/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
PubkeyAcceptedKeyTypes +ssh-rsa
HostKeyAlgorithms +ssh-rsa
After checking the above, connect with something like this:
Docker vs Vagrant
- [Recommended] Docker vs. Vagrant
Check out this infographic comparing Vagrant and Docker:
Infographic_docker-vs-vagrant-600px.jpg
- If you need isolation from the main environment and need to create multiple VE images quickly, Docker is recommended.
- For testing, debugging, and various scenarios, Docker is recommended.
- If the entire virtual environment must be separated, Vagrant is recommended.
Troubleshooting
An action 'destroy' was attempted on the machine 'default'
An action 'destroy' was attempted on the machine 'default',
but another process is already executing an action on the machine.
Vagrant locks each machine for access by only one process at a time.
Please wait until the other Vagrant process finishes modifying this
machine, then try again.
If you believe this message is in error, please check the process
listing for any "ruby" or "vagrant" processes and kill them. Then
try again.
This is a Vagrant lock problem. Either another process is running, or a previous process terminated abnormally and left the lock file behind.
Find and kill the "ruby" or "vagrant" processes:
PS C:\Users\zer0\Project> Get-Process | Where-Object {$_.ProcessName -like "*vagrant*"}
PS C:\Users\zer0\Project> Get-Process | Where-Object {$_.ProcessName -like "*ruby*"}
If the output looks like this:
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
241 20 102424 66480 7.34 11316 2 ruby
Kill them with something like this:
PS C:\Users\zer0\Project> Stop-Process -Name ruby -Force
PS C:\Users\zer0\Project> Stop-Process -Name vagrant -Force
See also
Favorite site
- Vagrant web site
- About Vagrant
- Managing development environments with Vagrant (simple VM management)
- [Recommended] Building virtual environments with Vagrant
- What is Vagrant?
Preview
- Automating development server setup with Vagrant and chef
- [http://www.slideshare.net/kthcorp/h3-2012-vagrant H3 2012: But it worked on my machine? - Setting up a development environment identical to the server with vagrant
Guide
- Vagrant tutorial: a tool for sharing development environments and managing virtual machines | 44BITS
- [Recommended] Create virtual machines with Vagrant! | blog.juho.kim