Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dorentus/c2063c9b434496a9d79b to your computer and use it in GitHub Desktop.
Save dorentus/c2063c9b434496a9d79b to your computer and use it in GitHub Desktop.
if not set -q __docker_vagrant_box_dir
set -gx __docker_vagrant_box_dir ~/opt/vagrant/docker
if not test -e $__docker_vagrant_box_dir/Vagrantfile
mkdir -p $__docker_vagrant_box_dir
wget 'https://gist.githubusercontent.com/dorentus/c2063c9b434496a9d79b/raw/Vagrantfile' -O $__docker_vagrant_box_dir/Vagrantfile
end
end
function docker
if not set -qx DOCKER_HOST
pushd $__docker_vagrant_box_dir
vagrant up; and set -Ux DOCKER_HOST "tcp://"(vagrant ssh-config | sed -n "s/[ ]*HostName[ ]*//gp")":2375";
popd
end
command docker $argv
end
function turn_off_docker_vagrant_box
pushd $__docker_vagrant_box_dir
vagrant halt; and set -e DOCKER_HOST
popd
end
  • Vagrantfile

  • boot2docker.fish

    • Fish-shell script
    • $__docker_vagrant_box_dir: folder for vagrant box, defaults to ~/opt/vagrant/docker, created from Vagrantfile if not exists. You might want to change it to a different location or use a different vagrant box.
    • function docker: bring up the vagrant box and run the original docker command
    • function turn_off_docker_vagrant_box : halt the vagrant box
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "parallels/boot2docker"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment