https://github.com/stenh0use/docker-machine-for-mac Skip to content Sign up * Why GitHub? + Features + Mobile + Actions + Codespaces + Packages + Security + Code review + Issues + Integrations + GitHub Sponsors + Customer stories * Team * Enterprise * Explore + Explore GitHub + Learn and contribute + Topics + Collections + Trending + Learning Lab + Open source guides + Connect with others + The ReadME Project + Events + Community forum + GitHub Education + GitHub Stars program * Marketplace * Pricing + Plans + Compare plans + Contact Sales + Education [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} stenh0use / docker-machine-for-mac Public * Notifications * Fork 3 * Star 160 * Docker Machine for Mac - an alternative to Docker for Mac 160 stars 3 forks Star Notifications * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags 3 branches 0 tags Code Latest commit @stenh0use stenh0use Merge pull request #4 from spookiej/update-debian-specs ... c285c80 Sep 17, 2021 Merge pull request #4 from spookiej/update-debian-specs Update debian specs c285c80 Git stats * 16 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time centos-stream8 add docker port to localhost May 25, 2021 debian-buster update debian specs Jul 27, 2021 resources fix missing \ Sep 14, 2021 .gitignore automate centos and debian installs May 3, 2021 README.md update order May 3, 2021 View code [ ] Docker for Mac - Docker Machine / Vagrant / Ansible Background Getting Started Setting up your hosts file Managing your docker-machine SSH access Mounting Volumes Exposing Ports Communicating with Mac OS localhost and DNS SELinux Author Information README.md Docker for Mac - Docker Machine / Vagrant / Ansible If you need docker and kernel modules to support things like SCTP, IP_VS, WireGuard etc. then this project might be for you. These Vagrant boxes are intended to replace Docker for Mac and utilises docker-machine, Vagrant, VirtualBox and Ansible to provide a fully featured linux vm. Motivation: Docker for Mac was proving to be a workflow pain rather than a workflow gain. It was slowing down my 16" Macbook Pro (32GB RAM, 6 CPUs), draining the battery, and causing the fans to constantly spin at full speed. There had also been occurrences where kernel modules had been removed, rendering it difficult to do system development. Background Vagrant and VirtualBox can be used to quickly build or rebuild virtual servers. This Vagrant profile installs docker using the Ansible provisioner and finishes up with the docker-machine configuration. Getting Started Each docker-machine directory contains a Vagrantfile for a different base operating systems (hereafter this folder shall be called the [vagrant_root]), which tells Vagrant how to set up your virtual machine in VirtualBox. To use the vagrant file, you will need to have done the following: 1. Download and Install VirtualBox 2. Download and Install Vagrant 3. If you want to completely remove Docker for Mac run this script (recommended) 4. If you removed Docker for Mac you'll then need to Download and install the docker cli binary 5. Install Docker Machine docker-machine 6. Install Ansible 7. Open a shell prompt (Terminal app on a Mac) and cd into the folder containing the Vagrantfile of the target operating systems that you want to build. Once all of that is done, you can simply type in make build, and Vagrant will create a new VM, install the base box, and configure it to work with docker. Once the new VM is up and running, you should see the message: Docker Machine setup was successful To connect to this host run "eval `docker-machine env `". To make this your default docker machine add the command or the output from "docker-machine env " to your ~/.bash_profile Setting up your hosts file If you want to modify your host machine's hosts file (/etc/hosts), to add the docker machine hostname you can do so adding the line below: eg. 192.168.33.3 docker-debian-10 (Where docker-debian-10) is the hostname you have configured in the Vagrantfile). If you'd like additional assistance editing your hosts file, please read How do I modify my hosts file? from Rackspace. Managing your docker-machine The setup of your docker machine is handled during the build stage. If you need to update or re-do this in any way the following commands are helpful. command description make build build a the docker-machine vm and configure for use with docker make destroy this will destroy the vagrant box and clean up the .vagrant directory the same as vagrant up, you can use this to make up start the docker-machine vm if it has already been built and needs to be started again. make down the same as vagrant halt, you can use this to shutdown your docker-machine vm. make add the vagrant box as a docker machine docker-machine-add make remove the vagrant box as a docker machine docker-machine-rm make check that the vagrant box is correctly setup as docker-machine-check a docker machine SSH access If you need or want ssh access to the vm you can ssh in with two methods. 1. The Vagrant method: from within the machines directory execute: vagrant ssh 2. The docker-machine method: from anywhere execute the command: docker-machine ssh Mounting Volumes The docker machine mounts the "/Users" folder in the docker VM to allow you to continue using the the existing functionality to mount volumes from the Mac locations. eg. docker run -d -v ~/dev/project/config.json:/opt/my_app/config.json -v $PWD:/data centos:7 More locations can be added if required in the Vagrant file. After updating with the new location execute vagrant reload to take effect. eg. config.vm.synced_folder "/Library", "/Library" Exposing Ports Any time you want to expose a port from docker you need to remember that the docker host will have changed from localhost to the IP address on the VM. If anyone has any good ideas to fix that magic let me know via the issues. If you really want to use localhost you can set a range in virtual box and port forward the ports that way. eg. exposing ports -p 8080:80 in docker will mean to query that port from your mac you would query the VM IP instead. curl http://192.168.33.3:8080 or if you configured your /etc/hosts as per the above instructions. curl http://docker-debian-10:8080 Communicating with Mac OS localhost and DNS The existing magic hostname (host.docker.internal) that lets docker containers talk to services on the Mac's localhost has been configured to use the Mac's interface IP address connected to the VM's private network. Any services on the Mac would need to be listing on this interface in order for this to work. Other custom hostnames can be configured if required by adding the variable dnsmasq_custom_hosts to the resources/vars/main.yml file. Usage: dnsmasq_custom_hosts: - hostname: custom.hostname.local ip_address: 192.168.3.1 SELinux CentOS Stream8 Docker Machine's docker daemon is configured with SELinux support enabled (selinux-enabled). Author Information James Stenhouse Vagrant file and Readme adapted from: Jeff Geerling, Ansible Vagrant Examples About Docker Machine for Mac - an alternative to Docker for Mac Topics docker docker-machine docker-for-mac Resources Readme Stars 160 stars Watchers 1 watching Forks 3 forks Releases No releases published Packages 0 No packages published Languages * Makefile 100.0% * (c) 2022 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.