Giter Club home page Giter Club logo

dockerhost's Introduction

Dockerhost

A Vagrantfile to host docker containers on your OSX machine in a Virtual Machine.

Why Vagrant over boot2docker?

It allows more flexibility then boot2docker, for instance setting up file sharing etc. File sharing is needed if you want to run PostgreSQL for example in development mode. You need a data directory to persist state.

This Vagranfile attaches a fixed ip to the VM: 10.2.0.10.

Getting started

1. Download and install Vagrant

Go and grab it on the Vagrant Download page

2. Clone the repository

git clone [email protected]:sgillis/dockerhost.git

3. Start the VM

$ cd dockerhost
vagrant up

4. Bash config

Add the following 3 lines to your .bashrc or .bash_profile file. This sets the docker host to your VM.

# This instructs docker to run containers on the VM and route traffic to the VM
export DOCKER_HOST="tcp://10.2.0.10:4243"
alias route-docker='sudo route -n add -net 172.17.0.0 10.2.0.10'

After you've added these lines you'll have to source your profile again:

source ~/.bash_profile

5. Use Docker

By now your VM is up and running and your environment is configured to use the VM as docker host.

docker info

Troubleshooting

When executing docker ps you might receive the following error (or similar):

An error occurred trying to connect: Get https://localhost:4243/v1.19/containers/json: tls: oversized record received with length 20527

Probably you've been using boot2docker. When you run boot2docker init it adds a few exports to your bash configuration. This conflicts with your vagrant config. Delete the following lines from your bash config:

export DOCKER_HOST=tcp://192.168.59.103:2376
export DOCKER_CERT_PATH=/Users/johndoe/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1

To be safe, unset these exports:

unset DOCKER_CERT_PATH
unset DOCKER_TLS_VERIFY

Now source your bash config again: source ~/.bash_profile.

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.