The project is to help project teams that are not ready to use the new Docker Desktop subscription.
It wasn't that long ago that in order to run a Docker Engine on a mac one had to setup their own virtual machine. When Docker Desktop arrived it made this process really easy by offering a one click solution. This repo is not going to provide a one click solution and it may not provide as an efficent method of running docker but hopefully it will help some project teams with the transition.
The first thing you need is to install some requierments. This project is currently setup with VirtualBox in mind but I think it could be adapted to other provides.
https://www.virtualbox.org/wiki/Downloads
brew install --cask virtualbox
brew install --cask vagrant
vagrant plugin install vagrant-sshfs (optional)
vagrant plugin install vagrant-notify-forwarder (optional but very useful for inotify to work)
# Clone this repo and run the following commands.
vagrant up
# This makes it easier to communicate with docker containers
# This IP address is defined in the Vagrantfile under private network
sudo echo "192.168.33.10 localdocker" >> /etc/hosts
# These commands only install the cli tools (which are open source)
brew install docker
brew install docker-compose
docker context create localdocker --docker "host=tcp://localdocker:2375"
docker context use localdocker
- We can improve this method and use ssh in the future. Docker supports "ssh://localdocker:22" but you need to either use the private key vagrant creates or you need to add your public key to the virtual machine.
You should be able to start docker containers like normal. You can use the localdocker to access containers as well.
docker run --rm -it -p 8080:80 nginx
# Open the link in your local browser and you should see the "Welcome to Nginx".
http://localdocker:8080
docker run --rm -it -v $(pwd)/webcode:/etc/nginx/sites -p 8080:80 nginx
docker-compose up
docker-compose build
The default way to share folders with docker is via Virtual Box shared folders. This method is not very efficiant and can be slow.
With an additional vagrant plugin you can use sshfs to share folders. This works better than the default shared folders but maybe not as well as SMB.
https://github.com/dustymabe/vagrant-sshfs
This might provide the most efficent experience between host and docker VM. This requries additional settings and you will be prompted for your password and SMB settings when first starting up or rebooting the VM.
https://www.vagrantup.com/docs/synced-folders/smb
# config.vm.synced_folder ENV["HOME"], ENV["HOME"]
# config.vm.synced_folder ENV["HOME"], ENV["HOME"], type: "sshfs"
config.vm.synced_folder ENV["HOME"], ENV["HOME"], type: "smb"
Many development tools use auto reload when source code is modified on the host. This is very useful for development so I recommend installing the additional plugin to forward host file notifications to the VM.
vagrant plugin install vagrant-notify-forwarder