Skip to content
This repository has been archived by the owner on Jan 1, 2021. It is now read-only.

Suggest dynamic config in boot2docker shellinit #944

Open
kevinSuttle opened this issue Jun 22, 2015 · 1 comment
Open

Suggest dynamic config in boot2docker shellinit #944

kevinSuttle opened this issue Jun 22, 2015 · 1 comment
Labels

Comments

@kevinSuttle
Copy link

For people like me who jump back and forth between VPN, firewalls, etc, setting the proper environment variable value for $DOCKER_HOST can be a pain because of DHCP.

I use fish, so this was my solution.

In config.fish:

set -x DOCKER_HOST tcp://(boot2docker ip):2376
set -x DOCKER_CERT_PATH /Users/(whoami)/.boot2docker/certs/boot2docker-vm

In more common shells like bash and zsh, you can just add a $.

set -x DOCKER_HOST tcp://$(boot2docker ip):2376
set -x DOCKER_CERT_PATH /Users/$(whoami)/.boot2docker/certs/boot2docker-vm

boot2docker shellinit should provide something like this to make the setup more dynamic and flexible.

@kevinSuttle kevinSuttle changed the title Suggest dynamic config Suggest dynamic config in boot2docker shellinit Jun 22, 2015
@kevinSuttle
Copy link
Author

This gets weird because of what I suspect is another bug. Trying to install https://github.com/codeclimate/codeclimate and I happened to get this bug.

❯ brew install codeclimate                                                                              12:40:53 PM
==> Installing codeclimate from codeclimate/homebrew-formulae
==> Downloading https://github.com/codeclimate/codeclimate/archive/v0.0.7.tar.gz
Already downloaded: /Library/Caches/Homebrew/codeclimate-0.0.7.tar.gz
==> env PATH=/usr/local/bin:/usr/local/Library/ENV/4.3:/usr/bin:/bin:/usr/sbin:/sbin PREFIX=/usr/local/Cellar/codecl
bin/check
An error occurred trying to connect: Get https://192.168.59.103:2376/v1.19/version: x509: certificate is valid for 127.0.0.1, 10.0.2.15, not 192.168.59.103
Unable to run `docker version', the docker daemon may not be running
Please ensure `boot2docker up' succeeds and you've run `boot2docker shellinit' in this shell
make: *** [install] Error 1

❯ boot2docker shellinit                                                                                 12:47:46 PM
Writing /Users/kevinsuttle/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /Users/kevinsuttle/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /Users/kevinsuttle/.boot2docker/certs/boot2docker-vm/key.pem
    set -x DOCKER_HOST tcp://192.168.59.103:2376
    set -x DOCKER_CERT_PATH /Users/kevinsuttle/.boot2docker/certs/boot2docker-vm
    set -x DOCKER_TLS_VERIFY 1

/Users/kevinsuttle
❯ boot2docker ip                                                                                        12:47:50 PM
192.168.59.103

Couple of things:

  1. The success of boot2docker up and boot2docker shellinit can be automated and checked programmatically.

Please ensureboot2docker up' succeeds and you've run boot2docker shellinit' in this shell.

  1. Both DOCKER_HOST and boot2docker ip report being set to 192.168.59.103, so the above error shouldn't be true.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants