download / install docker toolboxOSX install process#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 BasicsDisconnect without exiting ctrl+p ctrl+q copy file to containerdocker cp ./Documents/Scripts/foo.py newname:/tmp docker run -it -v $HOME/Documents/Scripts:/home/$USER/scripts --name testcontainer ubuntu bash docker run -it -v $HOME/Documents/Scripts:/home/$USER/scripts:ro --name testcontainer ubuntu bash docker run -it -v //c/temp/Scripts://temp --name testcontainer ubuntu bash https://docs.docker.com/installation/mac/#access-container-ports Docker from shellhttps://docs.docker.com/installation/mac/#from-your-shellSave your image to a filedocker save imagename -o filepath Creating an imagehttps://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 containerdocker exec -it testcontainer /bin/bash View container detailsjq to view json output docker inspect testcontainer | jq . get volume mapping info docker inspect --format "{{ .Volumes }}" testcontainer docker inspect -f "{{ .HostConfig.Links }}" testcontainer EntrypointAllows you to run the container as an executable. override entrypoint with docker run -it --entrypoint bash _____ Connect to the "hidden" docker VM on OS-Xscreen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty / # 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 |
Home >