Virtualbox Brew



Installing virtualbox via brew cask #5898. Closed rameshm76 opened this issue Aug 24, 2014 5 comments Closed Installing virtualbox via brew cask #5898. The VirtualBox from Brew Cask apparently installs the Oracle VirtualBox. Anyway with the future compability issues in mind, What is the compability status of Parallels and Virtualbox and is it possible to have them side-by-side? Are there some potential pitfalls?

What is Docker?

Docker is the next step on long IT containerization way. What does it mean? Years ago, you could run each application/process in particular container, that application couldn’t go outside the container which it was run. It was very safe but difficult to manage and not sharable. So you couldn’t easy share your container to other machine or to other developers to reuse for example by open source community.

So, that solution was a little bit complicated and worked only on Linux. Today we have Docker, which allows you to run containers on all operation systems. What is important, this tool is not only modern but also easy to manage and easy to share to others developers.
[toc]

Install Brew, VirtualBox, Vagrant and Vagrant-Manager, on a Macintosh 10.x Context: We will use Vagrant with VirtualBox. This guide is to help those unfamiliar with how to. Brew install-cask virtualbox-extension-pack. Name: Oracle VirtualBox Extension Pack. Installing virtualbox-extension-pack means you have AGREED to the license at. $ brew install virtualbox -cask ⚠️ It’s possible you’ll fail to install VirtualBox with an error message like this: When you do fail, turn on System Preference and see if ‘ System software from.

Other ways to install it

In this post, I want to show you how to install Docker by using brew which installation process I wrote last time. For me, it’s the easiest and safest way. But there are a few other possibilities to install it on Mac OS.

Docker.com – first method

First what you have to do is to go to Docker website and just download and run the .dmg file.

This is probably the easiest way, but unfortunately not the best. Using native install method you don’t have to install VirtualBox to run Linux, but sharing files between your Mac OS and systems in containers are really slowly. I can recommend that solution only if you want to test something or your project doesn’t use a framework with a lot of files.

Docker Toolbox – second method

It’s an app provided by Docker Company for Mac OS and Windows. The special feature in this toolbox is the requirement for VirtualBox, which will be a supervisor to run Linux. So, Docker is available as another machine in Docker environment. This toolbox contains also docker-compose (more below) and Kinematic, which allow you to manage your container by using GUI than a command line.

Install

I guess you have installed brew if not just follow this page and do everything that I’ve described.

If you are ready, open your terminal and type something like this:

If you have done it that you’ve received notice that docker-machine-driver-xhyve has to run as root, so you have to execute that commands:

Both commands will ask you for a password. Don’t worry to type it in a command line.

If everything goes ok then you can create your first docker machine, just type this command:

This command, as you suppose, creates a docker machine, using the xhyve driver.
--xhyve-experimental-nfs-share – this flag allows you to share each file in your /Users/ folder between Mac OS and Linux run on Docker.

Because you can have a lot docker machine, you can type this command in your terminal:

It registers a few variables, which allow you to use default docker machine without typing “default” each time.

Useful tools

Probably, you’ve noticed that with docker you installed also docker-machine and docker-compose. These tools are not required but they are the strength of docker.

docker-machine

This tool allows you to prepare a lot of docker machines on your Mac OS, so you can have a lot of containers on many Linux distributions. You can dump all available commands just by typing docker-machine --help but most likely you will use three of them:

I guess I don’t have to describe what exactly this commands do. It’s so obvious. One thing you need to know, if something goes wrong, just try to restart your docker machine.

docker-compose

The main goal of docker: you can write like this “one process = one container”, but each app requires a lot process it could be a PHP, HTTP server, some database etc. Of course, you can run containers for each process manually, which is not a big deal with 3 containers, but trust me it escalates very fast, so you need an easy tool to manage your container and to manage the dependencies because one container can require access to another container. For example, PHP app needs information from a database, but it doesn’t need access to HTTP server. Of course, and HTTP server requires access to PHP.

To work with docker-compose you need to create an YAML file called docker-composer.yml where you describe which container you want to create and how they are linked between each other.

That file can look like this:

As you can see, you are creating two containers, first, contains MySQL database and second one – a WordPress instance. This example is flattened, in normal case you should split WordPress instance to three another containers: PHP, HTTP server and one for WordPress files.

There is also created one volume, which contains files of MySQL database. This solution prevents loosing data when you turn off your Mac, or just reset docker-machine or this particular container.

If you want to read something more about parameters available in docker-compose file, you can just go to docker documentation.

docker-compose, as well as other tools, provides a lot of commands available from a terminal, the number one is:

This command runs all containers defined in your docker-compose file. If it is needed – rebuild and remove old unused containers.

How to use

Everything that you need is in the section above. You can manage of course each particular container directly from command line using command docker. But it’s just wasting a time.

Brew Install Virtualbox

Access by domain

Probably you want to access to your container by your web browser using some domains. You need to know what is IP of your docker machine and you can check it using command line just typing this:

You see IP and then use that IP in your /etc/hosts file.

Potential problems

Because you are trying to run Linux environment on Mac OS you can some across a lot strange problems if you want to use it in common work. Fortunately, you just need to follow some rules to enjoy work with docker.

Virtualbox brewing

Sharing files

If you installed a docker as described above you can share only files from your /Users/ folder. You can debug what is sharable directly on your docker machine, which can receive access directly from command line, like this:

Now, you are logged on your Linux and can browse to / and check is there /Users/ folder which contains files from your Mac OS. If you don’t see your files, just try to reinstall Docker and xhyve.

Speed of I/O process

Because docker needs transfer files between your Mac OS and Linux using the NFS it’s always more slowly then operation directly on your disk. So, if you want to boost up your application you have to remember to share only needed files. if you are backend develop you don’t share frontend javascript libraries, just put in into inside container.

Don’t forget to ignore cache and logs files!

Brew Virtualbox-dkms

Access via domain/IP

Restarting Mac OS or docker-machine sometimes restarts also IP of the docker machine. If you can’t connect to your docker just check the current IP using this command:

If it doesn’t work, you have to update domains in your /etc/hosts file.

In the following is a step by step guide to get you up and running with Vagrant and VirtualBox to run various operating systems, such as Ubuntu Linux, MacOS, Windows, etc. from your computer (the host).

Windows

Required Software

  • VirtualBox
  • Vagrant
  • GitBash

Step-by-step Installation Guide

  • Download URL: https://git-scm.com/download
    • During installation choose the following:
      • Use Git from the Windows Command Prompt with this option you will be able to use Git from both Git Bash and the Windows Command Prompt.
      • Checkout as-is, commit Unix-style line endings
  • Download and install VirtualBox https://www.virtualbox.org/wiki/Downloads
    • The current version is 6.0.10 (Sep. 2019)
      • After installing VirtualBox, open it and click File -> Preferences -> Extensions and click the marked icon
      • Select the downloaded extension pack and then click Install -> I Agree -> Yes
  • Download and install Vagrant (https://www.vagrantup.com/downloads.html)
  • Adapt the computer’s settings:
    • Enable VT-X (Intel Virtualization Technology) in your computer BIOS/UEFI. (OBS You enter your BIOS after restarting the computer and hit a key like F1, F2, up to F12 or DELETE. Which button to press depends on the vendor and the model of you computer. Find that in your computer’s manual.)
    • Disable Hyper-V on program and features page in the control panel.
  • If you did not already generate an SSH keypair, generate one (e.g., via ssh-keygen -t rsa in GitBash)
  • Now everything is installed. See if you can run vagrant --version in GitBash.

MacOS

Required Software

  • VirtualBox
  • Vagrant
  • Installed via homebrew

Step-by-step Installation Guide

  • Install VirtualBox and the Extension Pack https://www.virtualbox.org/wiki/Downloads. The current version is 6.0.10 (Sep. 2019)

  • Install Vagrant (https://www.vagrantup.com/downloads.html)

  • If you did not already generate an SSH keypair, generate one (e.g., via ssh-keygen -t rsa in GitBash)
  • Now everything is installed. See if you can run vagrant --version in GitBash.

Virtualbox Brew Install Error

Linux

Required Software

  • VirtualBox
  • Vagrant
  • Installed via apt

Step-by-step Installation Guide

Virtualbox Brewer

  • Install VirtualBox and the Extension Pack https://www.virtualbox.org/wiki/Downloads. The current version is 6.0.10 (Sep. 2019)

  • Install Vagrant (https://www.vagrantup.com/downloads.html)

  • If you did not already generate an SSH keypair, generate one (e.g., via ssh-keygen -t rsa in GitBash)
  • Now everything is installed. See if you can run vagrant --version in GitBash.

Creating Virtual Machines

Virtual machines (VM) are created from their specifications in a Vagrantfile. Get an example Vagrantfile with a description of a Windows 10, Ubuntu 16.04 and 18.04, and MacOS 10.14 VM-

  • Move that Vagrantfile to a directory of your liking (<vagrant_dir>)
  • Open a terminal (on Windows GitBash)
  • Start-up the VM:

  • The <vm_name> with the given Vagrantfile can be either macos, windows, ubuntu, ubuntu18

  • The first time you run the vagrant up command it will take a bit as it has to download the corresponding OS image. That is, to run this step, you have to be connected to the internet. Do not interrupt the process and keep track that potential errors.
  • To log onto the virtual machine from the command-line after completion of vagrant up execute:

    Alternatively, you can login via the GUI. For all OSes, the GUI login name should be vagrant and the password should be vagrant.
  • Now, you should be logged onto the VM and you should see a Bash prompt similar to:

  • When you are done working on your VM, you can leave it by issuing the exit command.

  • Subsequently, you can put the VM to “sleep” (just like closing the lid of your notebook) by running vagrant suspend on your host machine.

  • Or you can stop the VM (just like pressing the power botton) by running vagrant halt on your host machine.

  • In case you want to discard this VM just run vagrant destroy <vm_name> from within the directory containing the Vagrantfile.

  • Hint In case you want to modify the configuration of the virtual machine, which will be created, you can do this now. Edit it with an editor of your choice. For example, to give the VM more RAM adapt the line vb.memory = '6144' to a value of RAM in megabyte, which fits your host machine. That is, if you have 8GB of RAM and you want to give your VM 7GB of RAM change 6144 into 7168.

Virtualbox Brew

References

This guide is adapted from earlier versions and from https://www.swtestacademy.com/quick-start-vagrant-windows-10/