Coder Social home page Coder Social logo

docker-mac-vagrant's Introduction

Docker in Vagrant

This repository automates the provisioning of a Vagrant VM that acts as a hypervisor. In other words, it effortlessly replaces the slow parts of Docker for Mac. Your code runs faster, battery lasts longer and fans spin less - and you don't have to change anything about your projects.

D4M is slow. Primarily because of its osxfs/grpcfuse sharing filesystem. On the other hand, Parallels has their own proprietary fs sharing driver, and it works at almost native speeds. Unfortunately for us all, Vbox and VMWare do not seem to have the same performance.

Setting up

  1. Install and set up vagrant VM:
    ./setup.sh
  2. Set your preferred shared folder in the .env file, for example SHARE_PATH="$HOME/Sites/"
  3. Thats it, start vagrant with vagrant up.
  4. Add the following to VScode Settings:
    "docker.explorerRefreshInterval": 10000,
    "docker.host": "ssh://vagrant@workbox",

Usage

There are various ways to code in this setup. I have outlined my decisions in a thorough article.

Naked

๐Ÿ˜ช Files Editor/Interpreter Runtime
Host ๐Ÿ”ป ๐Ÿ”ป
VM ๐Ÿ”ป ๐Ÿ”ป

You can just go oldschool and keep coding on your local machine. Use your editor of choice. All the files will be sync-ed over to the containers at nearly native speeds. In other words, you run your Docker project as you usually would.

Reminder: You will need however, to have the language you use installed on your machine, if you hope to have intellisense.

Remote Interpreter

๐Ÿ’ฟ Files Editor/Interpreter Runtime
Host ๐Ÿ”ป
VM ๐Ÿ”ป ๐Ÿ”ป ๐Ÿ”ป

A better (albeit weird at first) way would be to share the code from your machine to the Parallels VM. Start containers. Refer to Remote coding How-tos section for directions on how to use the editors.

Here's an example - Host computer has no idea what Python is. I start the Docker container with Python inside. I click a button in VSCode, and it magically "teleports" itself into the container. You can now literally code within the container, without ever leaving the comfort of your editor. Of course, the files are on a volume so any changes you make are safely in sync with your local folder.

Container-first

๐Ÿ›ฐ Files Editor/Interpreter Runtime
Host
VM ๐Ÿ”ป ๐Ÿ”ป ๐Ÿ”ป

Important: Use container-first Branch!

Feeling adventurous? Don't use sharing at all. Provision the VM with your SSH key, and download your projects inside the VM. Use the rest the same as you would in the Remote Interpreter segment above. You will get an insane speed boost since you don't have any shared files between host and the VM - everything is only in VM.

Remote coding How-tos

I have written an extensive article on the topic, in short:

  • VSCode has a built in "Attach to remote Container" capability. It spawns a real editor and you work directly with the native interpreter within the container.
  • JetBrains "thick-ide" products like PHPStorm have a similar capability to be located on your host, but use a remote interpreter from within the container.

docker-mac-vagrant's People

Contributors

markomitranic avatar borisceranic avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.