All Articles

Vagrant install

Vagrant

설치

  • windows
    Download Vagrant

  • help

    >vagrant
    Usage: vagrant [options] <command> [<args>]
    
    -v, --version                    Print the version and exit.
    -h, --help                       Print this help.

Common commands: box manages boxes: installation, removal, etc. destroy stops and deletes all traces of the vagrant machine global-status outputs status Vagrant environments for this user halt stops the vagrant machine help shows the help for a subcommand init initializes a new Vagrant environment by creating a Vagrantfile login log in to HashiCorps Vagrant Cloud package packages a running vagrant environment into a box plugin manages plugins: install, uninstall, update, etc. port displays information about guest port mappings powershell connects to machine via powershell remoting provision provisions the vagrant machine push deploys code in this environment to a configured destination rdp connects to machine via RDP reload restarts vagrant machine, loads new Vagrantfile configuration resume resume a suspended vagrant machine snapshot manages snapshots: saving, restoring, etc. ssh connects to machine via SSH ssh-config outputs OpenSSH valid configuration to connect to the machine status outputs status of the vagrant machine suspend suspends the machine up starts and provisions the vagrant environment validate validates the Vagrantfile version prints current and latest Vagrant version

For help on any individual command run vagrant COMMAND -h

Additional subcommands are available, but are either more advanced or not commonly used. To see all subcommands, run the command vagrant list-commands.

1. 초기화
```sh
>vagrant init vagrant init ubuntu/xenial64
  1. Box 확인

    >vagrant box list
    There are no installed boxes! Use `vagrant box add` to add some.
  2. Box 삭제

    >vagrant box remove ubuntu/xenial64
    Box 'ubuntu/xenial64' (v20180525.0.0) with provider 'virtualbox' appears
    to still be in use by at least one Vagrant environment. Removing
    the box could corrupt the environment. We recommend destroying
    these environments first:

default (ID: a6895800a6314c5d939cfbe1f7b1f19b)

Are you sure you want to remove this box? [y/N] y Removing box ‘ubuntu/xenial64’ (v20180525.0.0) with provider ‘virtualbox’…

3.1 Box 위치
```sh
>dir %USERPROFILE%\.vagrant.d\boxes
  1. Plugin 설치

    >vagrant plugin install vagrant-vbguest
    Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
    Fetching: micromachine-2.0.0.gem (100%)
    Fetching: vagrant-vbguest-0.15.2.gem (100%)
    Installed the plugin 'vagrant-vbguest (0.15.2)'!
  2. 구동

    >vagrant up
    Bringing machine 'default' up with 'virtualbox' provider...
    ==> default: Checking if box 'ubuntu/xenial64' 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: Running 'pre-boot' VM customizations...
    ==> default: Resized disk: old 10240 MB, req 51200 MB, new 51200 MB
    ==> default: You may need to resize the filesystem from within the guest.
    ==> 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: Remote connection disconnect. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. 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 its present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
    ==> default: Machine booted and ready!
    [default] GuestAdditions versions on your host (5.2.12) and guest (5.1.34) do not match.
    Reading package lists...
    Building dependency tree...
    Reading state information...
    Package 'virtualbox-guest-dkms' is not installed, so not removed
    Package 'virtualbox-guest-x11' is not installed, so not removed
    The following packages will be REMOVED:
    virtualbox-guest-utils*
    0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
    After this operation, 2,342 kB disk space will be freed.
    (Reading database ... 54124 files and directories currently installed.)
    Removing virtualbox-guest-utils (5.1.34-dfsg-0ubuntu1.16.04.2) ...
    Purging configuration files for virtualbox-guest-utils (5.1.34-dfsg-0ubuntu1.16.04.2) ...
    Processing triggers for man-db (2.7.5-1) ...
    Reading package lists...
    Building dependency tree...
    Reading state information...
    linux-headers-4.4.0-127-generic is already the newest version (4.4.0-127.153).
    linux-headers-4.4.0-127-generic set to manually installed.
    The following additional packages will be installed:
    binutils cpp cpp-5 fakeroot gcc gcc-5 libasan2 libatomic1 libc-dev-bin
    libc6-dev libcc1-0 libcilkrts5 libfakeroot libgcc-5-dev libgomp1 libisl15
    libitm1 liblsan0 libmpc3 libmpx0 libquadmath0 libtsan0 libubsan0
    linux-libc-dev make manpages-dev
    Suggested packages:
    binutils-doc cpp-doc gcc-5-locales gcc-multilib autoconf automake libtool
    flex bison gdb gcc-doc gcc-5-multilib gcc-5-doc libgcc1-dbg libgomp1-dbg
    libitm1-dbg libatomic1-dbg libasan2-dbg liblsan0-dbg libtsan0-dbg
    libubsan0-dbg libcilkrts5-dbg libmpx0-dbg libquadmath0-dbg glibc-doc
    make-doc
    The following NEW packages will be installed:
    binutils cpp cpp-5 dkms fakeroot gcc gcc-5 libasan2 libatomic1 libc-dev-bin
    libc6-dev libcc1-0 libcilkrts5 libfakeroot libgcc-5-dev libgomp1 libisl15
    libitm1 liblsan0 libmpc3 libmpx0 libquadmath0 libtsan0 libubsan0
    linux-libc-dev make manpages-dev
    0 upgraded, 27 newly installed, 0 to remove and 0 not upgraded.
    Need to get 27.9 MB of archives.
    After this operation, 101 MB of additional disk space will be used.
    Get:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmpc3 amd64 1.0.3-1 [39.7 kB]
    Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 binutils amd64 2.26.1-1ubuntu1~16.04.6 [2,311 kB]
    Get:3 http://archive.ubuntu.com/ubuntu xenial/main amd64 libisl15 amd64 0.16.1-1 [524 kB]
    Get:4 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 cpp-5 amd64 5.4.0-6ubuntu1~16.04.9 [7,685 kB]
    Get:5 http://archive.ubuntu.com/ubuntu xenial/main amd64 cpp amd64 4:5.3.1-1ubuntu1 [27.7 kB]
    Get:6 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcc1-0 amd64 5.4.0-6ubuntu1~16.04.9 [38.8 kB]
    Get:7 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgomp1 amd64 5.4.0-6ubuntu1~16.04.9 [55.0 kB]
    Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libitm1 amd64 5.4.0-6ubuntu1~16.04.9 [27.4 kB]
    Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libatomic1 amd64 5.4.0-6ubuntu1~16.04.9 [8,882 B]
    Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libasan2 amd64 5.4.0-6ubuntu1~16.04.9 [264 kB]
    Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 liblsan0 amd64 5.4.0-6ubuntu1~16.04.9 [105 kB]
    Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libtsan0 amd64 5.4.0-6ubuntu1~16.04.9 [244 kB]
    Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libubsan0 amd64 5.4.0-6ubuntu1~16.04.9 [95.2 kB]
    Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcilkrts5 amd64 5.4.0-6ubuntu1~16.04.9 [40.1 kB]
    Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libmpx0 amd64 5.4.0-6ubuntu1~16.04.9 [9,774 B]
    Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libquadmath0 amd64 5.4.0-6ubuntu1~16.04.9 [131 kB]
    Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgcc-5-dev amd64 5.4.0-6ubuntu1~16.04.9 [2,242 kB]
    Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 gcc-5 amd64 5.4.0-6ubuntu1~16.04.9 [8,650 kB]
    Get:19 http://archive.ubuntu.com/ubuntu xenial/main amd64 gcc amd64 4:5.3.1-1ubuntu1 [5,244 B]
    Get:20 http://archive.ubuntu.com/ubuntu xenial/main amd64 make amd64 4.1-6 [151 kB]
    Get:21 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 dkms all 2.2.0.3-2ubuntu11.5 [66.3 kB]
    Get:22 http://archive.ubuntu.com/ubuntu xenial/main amd64 libfakeroot amd64 1.20.2-1ubuntu1 [25.5 kB]
    Get:23 http://archive.ubuntu.com/ubuntu xenial/main amd64 fakeroot amd64 1.20.2-1ubuntu1 [61.8 kB]
    Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc-dev-bin amd64 2.23-0ubuntu10 [68.7 kB]
    Get:25 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-libc-dev amd64 4.4.0-127.153 [870 kB]
    Get:26 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc6-dev amd64 2.23-0ubuntu10 [2,079 kB]
    Get:27 http://archive.ubuntu.com/ubuntu xenial/main amd64 manpages-dev all 4.04-2 [2,048 kB]
    dpkg-preconfigure: unable to re-open stdin: No such file or directory
    Fetched 27.9 MB in 25s (1,088 kB/s)
    Selecting previously unselected package libmpc3:amd64.
    (Reading database ... 54111 files and directories currently installed.)
    Preparing to unpack .../libmpc3_1.0.3-1_amd64.deb ...
    Unpacking libmpc3:amd64 (1.0.3-1) ...
    Selecting previously unselected package binutils.
    Preparing to unpack .../binutils_2.26.1-1ubuntu1~16.04.6_amd64.deb ...
    Unpacking binutils (2.26.1-1ubuntu1~16.04.6) ...
    Selecting previously unselected package libisl15:amd64.
    Preparing to unpack .../libisl15_0.16.1-1_amd64.deb ...
    Unpacking libisl15:amd64 (0.16.1-1) ...
    Selecting previously unselected package cpp-5.
    Preparing to unpack .../cpp-5_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking cpp-5 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package cpp.
    Preparing to unpack .../cpp_4%3a5.3.1-1ubuntu1_amd64.deb ...
    Unpacking cpp (4:5.3.1-1ubuntu1) ...
    Selecting previously unselected package libcc1-0:amd64.
    Preparing to unpack .../libcc1-0_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking libcc1-0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package libgomp1:amd64.
    Preparing to unpack .../libgomp1_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking libgomp1:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package libitm1:amd64.
    Preparing to unpack .../libitm1_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking libitm1:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package libatomic1:amd64.
    Preparing to unpack .../libatomic1_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking libatomic1:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package libasan2:amd64.
    Preparing to unpack .../libasan2_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking libasan2:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package liblsan0:amd64.
    Preparing to unpack .../liblsan0_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking liblsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package libtsan0:amd64.
    Preparing to unpack .../libtsan0_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking libtsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package libubsan0:amd64.
    Preparing to unpack .../libubsan0_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking libubsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package libcilkrts5:amd64.
    Preparing to unpack .../libcilkrts5_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking libcilkrts5:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package libmpx0:amd64.
    Preparing to unpack .../libmpx0_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking libmpx0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package libquadmath0:amd64.
    Preparing to unpack .../libquadmath0_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking libquadmath0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package libgcc-5-dev:amd64.
    Preparing to unpack .../libgcc-5-dev_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package gcc-5.
    Preparing to unpack .../gcc-5_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
    Unpacking gcc-5 (5.4.0-6ubuntu1~16.04.9) ...
    Selecting previously unselected package gcc.
    Preparing to unpack .../gcc_4%3a5.3.1-1ubuntu1_amd64.deb ...
    Unpacking gcc (4:5.3.1-1ubuntu1) ...
    Selecting previously unselected package make.
    Preparing to unpack .../archives/make_4.1-6_amd64.deb ...
    Unpacking make (4.1-6) ...
    Selecting previously unselected package dkms.
    Preparing to unpack .../dkms_2.2.0.3-2ubuntu11.5_all.deb ...
    Unpacking dkms (2.2.0.3-2ubuntu11.5) ...
    Selecting previously unselected package libfakeroot:amd64.
    Preparing to unpack .../libfakeroot_1.20.2-1ubuntu1_amd64.deb ...
    Unpacking libfakeroot:amd64 (1.20.2-1ubuntu1) ...
    Selecting previously unselected package fakeroot.
    Preparing to unpack .../fakeroot_1.20.2-1ubuntu1_amd64.deb ...
    Unpacking fakeroot (1.20.2-1ubuntu1) ...
    Selecting previously unselected package libc-dev-bin.
    Preparing to unpack .../libc-dev-bin_2.23-0ubuntu10_amd64.deb ...
    Unpacking libc-dev-bin (2.23-0ubuntu10) ...
    Selecting previously unselected package linux-libc-dev:amd64.
    Preparing to unpack .../linux-libc-dev_4.4.0-127.153_amd64.deb ...
    Unpacking linux-libc-dev:amd64 (4.4.0-127.153) ...
    Selecting previously unselected package libc6-dev:amd64.
    Preparing to unpack .../libc6-dev_2.23-0ubuntu10_amd64.deb ...
    Unpacking libc6-dev:amd64 (2.23-0ubuntu10) ...
    Selecting previously unselected package manpages-dev.
    Preparing to unpack .../manpages-dev_4.04-2_all.deb ...
    Unpacking manpages-dev (4.04-2) ...
    Processing triggers for libc-bin (2.23-0ubuntu10) ...
    Processing triggers for man-db (2.7.5-1) ...
    Setting up libmpc3:amd64 (1.0.3-1) ...
    Setting up binutils (2.26.1-1ubuntu1~16.04.6) ...
    Setting up libisl15:amd64 (0.16.1-1) ...
    Setting up cpp-5 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up cpp (4:5.3.1-1ubuntu1) ...
    Setting up libcc1-0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up libgomp1:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up libitm1:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up libatomic1:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up libasan2:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up liblsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up libtsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up libubsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up libcilkrts5:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up libmpx0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up libquadmath0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up gcc-5 (5.4.0-6ubuntu1~16.04.9) ...
    Setting up gcc (4:5.3.1-1ubuntu1) ...
    Setting up make (4.1-6) ...
    Setting up dkms (2.2.0.3-2ubuntu11.5) ...
    Setting up libfakeroot:amd64 (1.20.2-1ubuntu1) ...
    Setting up fakeroot (1.20.2-1ubuntu1) ...
    update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
    Setting up libc-dev-bin (2.23-0ubuntu10) ...
    Setting up linux-libc-dev:amd64 (4.4.0-127.153) ...
    Setting up libc6-dev:amd64 (2.23-0ubuntu10) ...
    Setting up manpages-dev (4.04-2) ...
    Processing triggers for libc-bin (2.23-0ubuntu10) ...
    Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
    Mounting Virtualbox Guest Additions ISO to: /mnt
    mount: /dev/loop0 is write-protected, mounting read-only
    Installing Virtualbox Guest Additions 5.2.12 - guest version is 5.1.34
    Verifying archive integrity... All good.
    Uncompressing VirtualBox 5.2.12 Guest Additions for Linux........
    VirtualBox Guest Additions installer
    Copying additional installer modules ...
    Installing additional modules ...
    VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
    VirtualBox Guest Additions: Starting.
    Unmounting Virtualbox Guest Additions ISO from: /mnt
    ==> default: Checking for guest additions in VM...
    ==> default: Mounting shared folders...
    default: /vagrant => D:/blockchain/dev
    default: /home/vagrant/exchange => D:/blockchain/dev/exchange

vagrant ssh Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-127-generic x86_64)

Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud

0 packages can be updated. 0 updates are security updates.

vagrant@ubuntu-xenial:~$ vagrant@ubuntu-xenial:~$

6. 종료
```sh
vagrant@ubuntu-xenial:~$ exit
logout
Connection to 127.0.0.1 closed.

>vagrant halt
==> default: Attempting graceful shutdown of VM...
```

7. 삭제
```sh
>vagrant destroy
    default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Destroying VM and associated drives...
```
Published 25 Oct 2017

속도보다 방향이 중요하다!
nadawoom on Twitter