{"id":13416570,"url":"https://github.com/shyiko/docker-vm","last_synced_at":"2025-09-05T17:39:48.718Z","repository":{"id":32198747,"uuid":"35772370","full_name":"shyiko/docker-vm","owner":"shyiko","description":"A simple and transparent alternative to boot2docker (backed by Vagrant)","archived":false,"fork":false,"pushed_at":"2016-09-24T17:45:47.000Z","size":16,"stargazers_count":39,"open_issues_count":2,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-07-31T21:57:13.628Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shyiko.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-17T15:56:29.000Z","updated_at":"2024-03-03T13:55:30.000Z","dependencies_parsed_at":"2022-07-26T04:18:43.520Z","dependency_job_id":null,"html_url":"https://github.com/shyiko/docker-vm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyiko%2Fdocker-vm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyiko%2Fdocker-vm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyiko%2Fdocker-vm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyiko%2Fdocker-vm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shyiko","download_url":"https://codeload.github.com/shyiko/docker-vm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225444525,"owners_count":17475355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T21:01:01.112Z","updated_at":"2024-11-20T00:04:55.780Z","avatar_url":"https://github.com/shyiko.png","language":"Shell","readme":"# docker-vm\n\nThe easiest way to get started with [Docker](https://www.docker.com/) on Mac OS X (tested on OS X Yosemite 10.10.1) \nand Windows (tested on Windows 10 Pro Insider Preview. Build 10074).\n\n#### Goals \n- Transparency \n    - Everything (excluding base VM definition) is in a single, under 50 lines long `Vagrantfile`. \n- Configurability\n    - Changes are inevitable so it's better when the process is quick and painless. Vagrant makes switching to a \n    different provider, changing base image (default one is \n    [Ubuntu 14.04 amd64 from phusion](https://github.com/phusion/open-vagrant-boxes)), etc. extremely easy.    \n- Performance  \n    - NFS/SMB instead of vboxsf (a.k.a. VirtualBox Shared Folders) \n    [by default](http://mitchellh.com/comparing-filesystem-performance-in-virtual-machines). rsync/unison when you need them. \n- Utility\n    - VM is controlled by [Vagrant](https://www.vagrantup.com/), meaning that you get stuff like `vagrant share`, \n    `vagrant package`, etc. out of box.\n\nYou are encouraged to fork and change this repo to suit **your needs**.\n\n## How does it work?\n\nWhen you boot the VM Docker starts listening on port 2376. Each time you call `docker` (or `docker-compose`, ...) on the host\nit sends a request (using the value of $DOCKER_HOST environment variable) to the guest OS. Together with `/Users/USERNAME -\u003e\n/Users/USERNAME` (on Mac OS X) and `C:\\Users\\USERNAME -\u003e /c/Users/USERNAME \u0026 /cygwin/c/Users/USERNAME` mapping it allows\nto use Docker client the way you would on Linux (sort of).\n\n## Installation\n\nIrrespective of whether you're going to go with \"Automated\" or \"Manual\" setup, please make sure you have\n[Git](https://git-scm.com/downloads), [Docker](https://docs.docker.com/installation/binaries/) client (grab it from [here](https://docs.docker.com/installation/binaries/) (latest - Mac OS X: [x86_64](https://get.docker.com/builds/Darwin/x86_64/docker-latest.tgz) / Windows: [i386](https://get.docker.com/builds/Windows/i386/docker-latest.zip)/[x86_64](https://get.docker.com/builds/Windows/x86_64/docker-latest.zip))) (tested on 1.6.1),\n[Vagrant](https://www.vagrantup.com/downloads.html) (tested on 1.7.2) \u0026\n[VirtualBox](https://www.virtualbox.org/wiki/Downloads) (tested on 4.3.26) installed.\n\n### Automated (Mac OS X only)\n\n```sh\ncurl -o- https://raw.githubusercontent.com/shyiko/docker-vm/master/install.sh | bash\n```\n\u003e (reopen terminal/tab on completion)\n\nNOTE that if you get something like \"-bash: docker-vm: command not found\" then it's probably because ~/.bashrc is not \nsourced from ~/.bash_profile. In that case run `echo 'if [ -f ~/.bashrc ]; then source ~/.bashrc; fi' \u003e\u003e ~/.bash_profile` and restart your terminal/tab.\n\nThe script clones the docker-vm repository to ~/.docker-vm and adds initialization\ncode to ~/.bashrc (or ~/.bash_profile, ~/.zshrc, ~/.profile, whichever it finds first).\nIt also appends `192.168.42.10 docker-vm` to the /etc/hosts so that you would be able to reference\nVM by name and not just ip address (e.g. `http://docker-vm:8000/`).\n\nYou can customize repository url, checkout directory and profile using the\nDOCKER_VM_SOURCE, DOCKER_VM_DIR, and PROFILE variables (e.g.\n`curl ... | DOCKER_VM_SOURCE=http://github.com/YOUR_NAME/docker-vm.git bash` to\nuse your fork instead of this repo).\n\n### Manual\n\n* Mac OS X\n\n```sh\ngit clone https://github.com/shyiko/docker-vm.git ~/.docker-vm\n\n# NOTE: unless you want to execute lines below every time you open up a new terminal/tab -\n#       consider adding them to the ~/.bash_profile (or whichever profile you use)\n#       (more on that here - http://ss64.com/osx/syntax-bashrc.html)\ndocker-vm() ( cd ~/.docker-vm \u0026\u0026 exec vagrant \"$@\" )\n\nexport DOCKER_HOST=tcp://192.168.42.10:2376\nunset DOCKER_TLS_VERIFY # if boot2docker is installed\n```\n\n* Windows\n\n\u003e MSYS/Cygwin users only: see installation instructions for Mac OS X.\n\n(execute in `cmd`)\n\n```sh\ngit clone https://github.com/shyiko/docker-vm.git \"%USERPROFILE%/.docker-vm\"\n\n(\necho @ECHO OFF\necho SETLOCAL\necho cd /D ^%USERPROFILE^%\\.docker-vm\necho vagrant %*\necho ENDLOCAL\n) \u003e %SystemRoot%\\system32\\docker-vm.bat\n\nset DOCKER_HOST=tcp://192.168.42.10:2376\nunset DOCKER_TLS_VERIFY\n```\n\n## Usage\n\n```sh\ndocker-vm up # boot up the vm (check \"docker-vm --help\" for the list of available commands)\n\n# verify that docker client is able to connect to the daemon running inside the vm\ndocker version\n\n# start using docker *\ndocker run -v $(pwd):/usr/share/nginx/html -d -p 8080:80 nginx\necho \"hello world\" \u003e index.html\nopen http://docker-vm:8080/ # **\n```\n\n\\* on Windows `$(pwd)` needs to be replaced with /c/Users/USERNAME/... (unless you are using MSYS/Cygwin)\n\n\\** if you don't have `192.168.42.10 docker-vm` in `/etc/hosts`\n(or [equivalent](http://superuser.com/questions/525688/whats-the-windows-equivalent-of-etc-hosts) on Windows) -\nreplace `http://docker-vm:8080/` with `http://192.168.42.10:8080/`.\n\n\u003e Note that `docker-vm` is basically just an alias for `vagrant` which means that\nyou can use all the [commands](https://docs.vagrantup.com/v2/cli/index.html) supported by the latter (e.g. `docker-vm suspend`, `docker-vm status`, ...).\n\nGetting things to work on Windows can be a little bit tricky (what a suprise, right). Check out the \"Troubleshooting\" section (further in the document) if you experience any problems with `docker-vm up`.\n\n## A note on docker-compose\n\nRight now [docker-compose](https://github.com/docker/compose) is available for Linux / Mac OS X only. Windows support is coming in [docker/compose#1085](https://github.com/docker/compose/issues/1085). Until then, one way to get docker-compose on Windows is to:\n\n1. Enter the VM with `docker-vm ssh` and install docker-compose by executing ```sudo sh -c \"curl -L https://github.com/docker/compose/releases/download/1.3.2/docker-compose-`uname -s`-`uname -m` \u003e /usr/local/bin/docker-compose \u0026\u0026 chmod +x /usr/local/bin/docker-compose\"```.\n\n2. Create docker-compose alias. If you are using MSYS/Cygwin then it's a matter of adding `docker-compose() ( docker-vm ssh -c \"cd $(pwd) \u0026\u0026 exec docker-compose $*\" )` to ~/.bashrc, otherwise - execute (in `cmd`): \n    ```sh\n    (\n    echo @ECHO OFF\n    echo SETLOCAL\n    echo SET pwd=^%cd^:\\=/%\n    echo docker-vm ssh -c ^\"cd ^%pwd^:C:/=/c/% ^\u0026^\u0026 exec docker-compose %*^\"\n    echo ENDLOCAL\n    ) \u003e %SystemRoot%\\system32\\docker-compose.bat\n    ```\n\n## Advanced\n \n### Performance considerations \n\nSooner or later, chances are that you'll have to deal with a lot of small files. And the things is - neither vboxsf nor NFS/SMB \nmay be up to the task. Here are some numbers to visually demonstrate the issue (time taken to make a copy of \n`node_modules` containing 32k of files / 290mb in size on MacBook Pro (Retina, Mid 2012), obviously YMMV):\n\n| VirtualBox native | native | Network File System (NFS) | VirtualBox Shared Folders (vboxsf) |\n| ----------------- | ------ | ----- | ------ |\n| 17.5s             | 18.5s  | 2m10s | 3m25s  |\n\nThe good new is - you can continue using NFS/SMB or even vboxsf (as they are not that bad when you have fewer files) and switch to \n`rsync`/`unison` only when necessary (more on that in a bit). The solution is to use `mount -o bind`, which\nallows to mount arbitrary directory over the other already mounted one (including subtree), like so:    \n\n```sh\ndocker-vm ssh -c \"\n    SOURCE_DIR=/Users/USERNAME/Projects \u0026\u0026\n    MOUNT_ROOT=/home/vagrant/.mnt \u0026\u0026\n    mkdir -p $MOUNT_ROOT/$SOURCE_DIR \u0026\u0026 \n    sudo mount -o bind $MOUNT_ROOT/$SOURCE_DIR $SOURCE_DIR\"        \n``` \n\nAfter that just `rsync`/`unison` files to `$MOUNT_ROOT/$SOURCE_DIR`.\n\n#### Uni-directional syncing (using rsync)\n\nCheck out \"vagrant [rsync](https://docs.vagrantup.com/v2/cli/rsync.html)\" and \"vagrant [rsync-auto](https://docs.vagrantup.com/v2/cli/rsync-auto.html)\". \nFor a one time sync you may find `rsync -av SOURCE_DIR vagrant@192.168.42.10:TARGET_DIR` (password is `vagrant`) to be more convenient, though.\n\n#### Bi-directional syncing (using [unison](https://www.cis.upenn.edu/~bcpierce/unison/index.html)) \n\n\u003e `unison` must be installed both on host and guest OSs (**make sure versions match**).  \nOn Mac OS X - `brew install unison` (2.48.3 at the time of writing).   \nOn Windows - `choco install unison -version 2.48.3` (provided [chocolatey](https://chocolatey.org/) is installed).\n\n\u003e To install unison inside the VM:   \n`sudo apt-get update \u0026\u0026 sudo apt-get install -y ocaml build-essential exuberant-ctags \u0026\u0026\ncurl http://www.seas.upenn.edu/~bcpierce/unison/download/releases/unison-2.48.3/unison-2.48.3.tar.gz | tar xz -C /tmp \u0026\u0026\n(cd /tmp/unison-* \u0026\u0026 make UISTYLE=text \u0026\u0026 sudo cp unison /usr/local/bin/)`\n\n```sh\n# start unison daemon\ndocker-vm ssh -c \"unison -socket 5000\"\n \n# start syncing (see `unison -help` for more information)  \nunison SOURCE_DIR socket://192.168.42.10:5000/TARGET_DIRECTORY \\\n    -terse -auto -prefer=SOURCE_DIR -batch -repeat 3\n```\n\n#### Mounting NFS volumes manually\n\n(it might come in handy if you don't want your whole /Users/USER directory to be mounted inside the VM and \n narrowing paths with multiple `config.vm.synced_folder` feels too \"static\") \n \n```sh \ndocker-vm ssh -c \"mkdir -p SOURCE_DIRECTORY \u0026\u0026 \n    mount -o 'vers=3,udp' 192.168.42.1:SOURCE_DIRECTORY SOURCE_DIRECTORY\"\n``` \n\n\u003e Don't forget to update /etc/fstab (in your guest OS) if you want to make this link persistent.      \n\n## Troubleshooting\n\n* (issue [#12182](https://www.virtualbox.org/ticket/12182))\n  C:\\\u003edocker-vm up  \n  VBoxManage.exe: error: Failed to create the host-only adapter\n  ...\n  \n  WORKAROUND: Settings -\u003e View Network Connections -\u003e Ethernet N -\u003e\n  Details... -\u003e select \"Internet Protocol Version 4 (TCP/IPv4)\" -\u003e Properties -\u003e set \"IP address\" to 192.168.42.1. \n  Try vagrant up again.  \n\n* C:\\\u003edocker-vm up  \n  The guest machine entered an invalid state while waiting for it to boot. Valid states are 'starting, running'. The machine is in the 'poweroff' state. Please verify everything is configured properly and try again.\n\n  WORKAROUND: Start VirtualBox, select VM named docker-vm... and click 'Start'. If you get an error similar to 'Failed to open a session for the virtual machine docker-vm... . VT-x is not available. (VERR_VMX_NO_VMX).' then [turn Hyper-V off](http://www.hanselman.com/blog/SwitchEasilyBetweenVirtualBoxAndHyperVWithABCDEditBootEntryInWindows81.aspx).\n\n* (issue [#3139](https://github.com/mitchellh/vagrant/issues/3139))\n  C:\\\u003edocker-vm up  \n  Clearing any previously set forwarded ports  \n  ... or similar and then it just hangs.  \n\n  SOLUTION: Either install [PowerShell 3](http://www.microsoft.com/en-us/download/details.aspx?id=34595) or remove/comment out \", type: smb\" in [Vagrantfile](https://github.com/shyiko/docker-vm/blob/master/Vagrantfile#L25). See related issue for more information. \n\n* C:\\\u003edocker-vm ssh  \n  `ssh` executable not found in any directories in the %PATH% variable. Is an\n  SSH client installed? Try installing Cygwin, MinGW or Git, all of which\n  contain an SSH client. Or use your favorite SSH client with the following\n  authentication information shown below:\n  ...\n  \n  SOLUTION: Install [Git for Windows](http://git-scm.com/download/win) (tested on 1.9.5) and make sure \n  \"C:\\Program Files (x86)\\Git\\bin\" is on the [PATH](http://www.computerhope.com/issues/ch000549.htm).\n   \n","funding_links":[],"categories":["Development with Docker","Local Container Manager"],"sub_categories":["Development Environment"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshyiko%2Fdocker-vm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshyiko%2Fdocker-vm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshyiko%2Fdocker-vm/lists"}