Vagrant

ETC

Language :

Vagrant

파일 연동 관리 쉬움

0. 설치

1. Vagrant Cloud (https://app.vagrantup.com/boxes/search)

VM에 설치한 OS-버전 검색

2. CMD 에서 Vagrant Box 추가

>vagrant box add bento/centos-6.9
==> box: Loading metadata for box 'bento/centos-6.9'
    box: URL: https://vagrantcloud.com/bento/centos-6.9
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) hyperv
2) parallels
3) virtualbox
4) vmware_desktop

Enter your choice: 3
==> box: Adding box 'bento/centos-6.9' (v201803.24.0) for provider: virtualbox
    box: Downloading: https://vagrantcloud.com/bento/boxes/centos-6.9/versions/201803.24.0/providers/virtualbox.box
    box: Progress: 100% (Rate: 343k/s, Estimated time remaining: --:--:--)
==> box: Successfully added box 'bento/centos-6.9' (v201803.24.0) for 'virtualbox'!
  • vagrant box list : 다운로드된 box 목록
  • vagrant box remove [삭제할 box] : box 삭제

3.  Vagrantfile 저장 위치 선정

>cd documents/vagrant

4. 설치

Documents\Vagrant>vagrant init
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

5. Vagrantfile 수정

  config.vm.box = "bento/centos-6.9"					// 사용하려는 box 이름

6. 가상머신 생성

PowerShell에서 실행한다. CMD에서 동작하지 않는다.

Visual Studio Code> Vagrantfile 저장되어 있는 폴더 열기 > 터미널 [Ctrl + `] 활성

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\dico\Documents\Vagrant> vagrant up --provider virtualbox
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/centos-6.9'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/centos-6.9' is up to date...
==> default: Setting the name of the VM: Vagrant_default_1522469207407_35628
Vagrant is currently configured to create VirtualBox synced folders with
the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant
guest is not trusted, you may want to disable this option. For more
information on this option, please refer to the VirtualBox manual:

  https://www.virtualbox.org/manual/ch04.html#sharedfolders

This option can be disabled globally with an environment variable:

  VAGRANT_DISABLE_VBOXSYMLINKCREATE=1

or on a per folder basis within the Vagrantfile:

  config.vm.synced_folder '/host/path', '/guest/path', SharedFoldersEnableSymlinksCreate: false
==> 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 aborted. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/M_K/Documents/Vagrant
  • vagrant up : 현재 Vagrantfile 환경을 부팅한다

7. 가상머신 접속

PS C:\Users\dico\Documents\Vagrant> vagrant ssh
[vagrant@localhost ~]$

8. 관리자 로그인

[vagrant@localhost src]$ su
Password:								// vagrant
[root@localhost src]#

민갤

Back-End Developer

백엔드 개발자입니다.