docker

download / install docker toolbox

https://www.docker.com/toolbox

OSX install process

https://docs.docker.com/installation/mac/

#run ifconfig find interface name for virtual box (vboxnet0)

ifconfig | grep vboxnet

#expect ping to fail

ping 192.168.99.100

#display route table before adding route

netstat -nr

#add route

sudo route -nv add -net 192.168.99 -interface vboxnet0

#display route table after adding route

netstat -nr

#should be able to ping now

ping 192.168.99.100 

docker-machine ls

docker-machine start default

docker-machine env default

eval "$(docker-machine env default)"

docker run hello-world

docker run -it ubuntu bash

connect to docker host

docker-machine ssh default

docker ps -a

docker rename fb3eea6a400f newname

docker start newname

docker attach newname

Basics

https://docs.docker.com/articles/basics/

Disconnect without exiting

ctrl+p ctrl+q

copy file to container

docker cp ./Documents/Scripts/foo.py newname:/tmp

Mount a volume

https://docs.docker.com/installation/mac/#mount-a-volume-on-the-container

docker run -it -v $HOME/Documents/Scripts:/home/$USER/scripts --name testcontainer ubuntu bash

mount as read-only

docker run -it -v $HOME/Documents/Scripts:/home/$USER/scripts:ro --name testcontainer ubuntu bash

mount on a windows box

docker run -it -v //c/temp/Scripts://temp --name testcontainer ubuntu bash

https://docs.docker.com/installation/mac/#access-container-ports

Docker from shell

https://docs.docker.com/installation/mac/#from-your-shell

Save your image to a file

docker save imagename -o filepath

Creating an image

https://docs.docker.com/userguide/dockerimages/

mkdir -p docker/tinkerbox

cd docker/tinkerbox/

vi Dockerfile

# This is a comment

FROM ubuntu:14.04

MAINTAINER Kevin Curran <kevin@blah.com>

RUN apt-get update && apt-get install -y python python-requests

docker build -t kevin/tinkerbox:v1 .

docker images

docker run -t -i kcurran/tinkerbox:v1 /bin/bash

Run a command in a running container

https://docs.docker.com/reference/commandline/exec/

docker exec -it testcontainer /bin/bash

View container details

jq to view json output

https://docs.docker.com/reference/commandline/inspect/

docker inspect testcontainer | jq .

get volume mapping info

docker inspect --format "{{ .Volumes }}" testcontainer

docker inspect -f "{{ .HostConfig.Links }}" testcontainer

Entrypoint

https://docs.docker.com/engine/reference/builder/#/entrypoint

Allows you to run the container as an executable.

override entrypoint with 

docker run -it --entrypoint bash _____

Connect to the "hidden" docker VM on OS-X

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

^A k to exit

/ # cat /etc/motd

Welcome to Moby, based on Alpine Linux.

/ # ps axuwwf | grep dockerd

 1698 root       0:00 /usr/bin/dockerd --pidfile=/run/docker.pid -H unix:///var/run/docker.sock --swarm-default-advertise-addr=eth0 --debug --storage-driver aufs