Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
macOS VirtualBox headless Ubuntu Server and Docker setup

Get started

Install virtualbox and the extension pack:

brew cask install docker virtualbox virtualbox-extension-pack

Download the ubuntu server image and create a VBox for it, the rest of the readme assumes it is named "Ubuntu Server".

Enable SSH

In the box

sudo apt install openssh-server

On the host

VBoxManage modifyvm "Ubuntu Server" --natpf1 "ssh,tcp,,3022,,22"

This will forward the ssh port 22 to the host on 3022. Next, start the server without a window:

VBoxManage startvm "Ubuntu Server" --type headless

And connect to it:

ssh -p 3022 username@

Install docker

Once your ssh session is running in the box:

Add yourself to the docker and vboxsf group:

sudo usermod -aG docker,vboxsf `whoami`;
sudo reboot
  • vboxsf is needed to access shared folders.
  • docker is needed to see the docker daemon.

Shared folders

Mounting shared folders in Ubuntu Server

You can mount host folders in the VirtualBox:

The only thing that's changed is the command sudo /media/cdrom/ (not

Shares are visible under /media/sf_<name-of-share>.


Install by running the following (curl method did not work for me so using pip):

sudo apt install python-pip;
export LC_ALL=C; #
pip install docker-compose;

Some handy aliases

echo "alias d='docker'" >> .bashrc;
echo "alias dc='docker-compose'" >> .bashrc;
source .bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.