Docker Interaction Process
CLI utility for straightforward provisioning and interacting with an application configured by docker-compose.
DIP also contains commands for running support containers such as ssh-agent and DNS server.
https://github.com/bibendi/dip/releases
brew tap bibendi/dip
brew install dip
TODO
dip --help
dip SUBCOMMAND --help
version: '1'
environment:
COMPOSE_EXT: development
RAILS_ENV: development
BUNDLE_PATH: /bundle
compose:
files:
- docker/docker-compose.yml
- docker/docker-compose.$COMPOSE_EXT.yml
project_name: bear$RAILS_ENV
interaction:
sh:
service: app
bundle:
service: app
command: bundle
rake:
service: app
command: bundle exec rake
rspec:
service: app
environment:
RAILS_ENV: test
command: bundle exec rspec
rails:
service: app
subcommands:
s:
service: web
c:
command: bundle exec rails c
psql:
service: app
command: psql -h pg -U postgres bear
provision:
- docker volume create --name bundle_data
- dip sh ./script/config_env
- dip compose up -d pg redis
- dip bundle install
- dip rake db:migrate --trace > /dev/null
Run commands defined in interaction
section of dip.yml
dip run rails c
dip run rake db:migrate
run
argument can be ommited
dip rake db:migrate
Run commands each by each from provision
section of dip.yml
Run docker-compose commands that are configured according with application dip.yml
dip compose COMMAND [OPTIONS]
dip compose up -d redis
Runs ssh-agent container base on https://github.com/whilp/ssh-agent with your ~/.ssh/id_rsa.
It creates a named volume ssh_data
with ssh socket.
An applications docker-compose.yml should define environment variable SSH_AUTH_SOCK=/ssh/auth/sock
and connect to external volume ssh_data
.
dip ssh add
docker-compose.yml
services:
web:
environment:
- SSH_AUTH_SOCK=/ssh/auth/sock
volumes:
- ssh-data:/ssh:ro
volumes:
ssh-data:
external:
name: ssh_data
Runs DNS server container based on https://github.com/aacebedo/dnsdock
dip dns up
TODO
First, let's start by configuring the default Docker service DNS server to IP where the DNS server will run (172.17.0.1
). Currently, this requires SSH'ing into the VM and editing /etc/default/docker
ssh docker@local.docker
vi /etc/default/docker
# Add the DNS server static IP via `--bip` and `--dns`
# Change DOCKER_ARGS to:
DOCKER_ARGS="-H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 -s btrfs --bip=172.17.0.1/24 --dns=172.17.0.1"
# save :x
exit
dlite stop && dlite start
Lastly, configure OSX so that all .docker
requests are forwarded to Docker's DNS server. Since routing has already been taken care of, just create a custom resolver under /etc/resolver/docker
with the following content:
nameserver 172.17.0.1
Then restart OSX's own DNS server:
sudo killall -HUP mDNSResponder
By default, Docker creates a virtual interface named docker0
on the host machine that forwards packets between any other network interface.
However, on OSX, this means you are not able to access the Docker network directly. To be able to do so, you need to add a route and allow traffic from any host on the interface that connects to the VM.
Run the following commands on your OSX machine:
sudo route -n add 172.17.0.0/8 local.docker
DOCKER_INTERFACE=$(route get local.docker | grep interface: | cut -f 2 -d: | tr -d ' ')
DOCKER_INTERFACE_MEMBERSHIP=$(ifconfig ${DOCKER_INTERFACE} | grep member: | cut -f 2 -d: | cut -c 2-4)
sudo ifconfig "${DOCKER_INTERFACE}" -hostfilter "${DOCKER_INTERFACE_MEMBERSHIP}"
Check:
ping dnsdock.docker
TODO
brew install docker
brew switch docker 1.12.1
Download https://github.com/nlf/dlite/releases/download/1.1.5/dlite
sudo dlite install -c 2 -m 4 -d 20 -S $HOME
dlite stop
- download
bzImage
androotfs.cpio.xz
https://github.com/bibendi/dhyve-os/releases/tag/2.3.1 - move in
~/.dlite/
dlite start
git clone https://github.com/nlf/dhyve-os.git
cd dhyve-os
git checkout legacy
vi Dockerfile
# find the DOCKER_VERSION and replace with needed version
make
dlite stop
cp output/{bzImage,rootfs.cpio.xz} ~/.dlite/
dlite start