WellSpring

WSL2 + Vagrant 환경 구성 본문

Tip & Tips

WSL2 + Vagrant 환경 구성

daniel00324 2024. 12. 18. 22:10

1. Install Vagrant

1) WSL2 에서 Vagrant 설치

# run inside WSL 2
# check https://www.vagrantup.com/downloads for more info
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install vagrant

 

2)   enable WSL 2 support ( add below 2-lines into ~/.bashrc )

# append those two lines into ~/.bashrc
echo 'export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"' >> ~/.bashrc
echo 'export PATH="$PATH:/mnt/c/Program Files/Oracle/VirtualBox"' >> ~/.bashrc

# now reload the ~/.bashrc file
source ~/.bashrc

2. Install virtualbox_WSL2 plugin

1) Install Vagrant Plug-In

 ⚠ Since September 2021 vagrant starts to fail with an error like this one:

더보기
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/bionic64' version '1.0.282' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection refused. Retrying...
    default: Warning: Connection refused. Retrying...
    default: Warning: Connection refused. Retrying...
    default: Warning: Connection refused. Retrying...
    default: Warning: Connection refused. Retrying...
    default: Warning: Connection refused. Retrying...
==> default: Waiting for cleanup before exiting...

In order to fix it, an older solution from the community still solves the problem:

# install vagrant on WSL2
sudo apt install vagrant
# Install virtualbox_WSL2 plugin
vagrant plugin install virtualbox_WSL2
더보기

Step1. vagrant 패키지 설치하기

 

Step2. vagrant plug-In 설치 (on WSL2)

[ Error 화면 : Windows 용 vagrant 가 먼저 설치되어 있어 제거했다 ~ ㅡㅡ;; ]
[ 삭제 후 , 재구성 되는 과정 ]
[ 설치 후, 재기동 하면 완료 !! ]

 

☞ You can check the source code at:
- https://github.com/Karandash8/virtualbox_WSL2


[ 참조 링크 모음 ]