So I am a recent MAC convert. Although I am a long time Ubuntu Fan and user but I got tired of switching OS between windows and linux , hacking around virtual box. Also I am more and more working on cloud platform now a days and using my machine as a thin client.
The first thing I wanted on mac is to pull my docker images and use them locally. However, Os X doesn’t support docker images natively. So the docker team came up with this excellent tool called docker-machine. More about docker machine here:
https://docs.docker.com/engine/installation/mac/
When you install docker toolbox , it also installs a ‘Docker Quickstart Terminal’ which you can use to get started with docker. But if you are like me, you want access to your docker engine from any terminal natively.
#find your local docker-machine ip (it should be 192.168.99.100) $ docker-machine ip 192.168.99.100 #verify your certs exists ~$ ls ~/.docker/machine/ cache certs machines no-error-report #who are you? ~$ whoami sajid #Update ~/.bash_profile $vi ~/.bash_profile export DOCKER_HOST=tcp://192.168.99.100:2376 export DOCKER_TLS_VERIFY=1 export DOCKER_CERT_PATH=/Users/sajid/.docker/machine/machines/default #reload ~$ source ~/.bash_profile
What this does is it lets your local docker client point to your default docker-engine / docker-daemon.
Now you can run docker commands just like you can do on linux natively.
~$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE williamyeh/ansible ubuntu14.04-onbuild ffb3155960ee 3 weeks ago 244.8 MB ubuntu latest b549a9959a66 3 weeks ago 188 MB jenkins 2.0-beta-1 a08ca387230c 3 weeks ago 711.9 MB sameersbn/redis latest 100e6eb3355d 5 weeks ago 196.5 MB hello-world latest 690ed74de00f 6 months ago 960 B sajidmoinuddin.duckdns.org:5000/hello-world latest 690ed74de00f 6 months ago 960 B sameersbn/gitlab 7.14.3 ffbbcd99823b 7 months ago 631.6 MB sameersbn/postgresql 9.4-3 40e7e3862c0c 8 months ago 231.6 MB
Once you configure your docker client, the next thing you would want is to push some local image in your insecure registry (note my environment is running behind a strict firewall, so its ok to run in insecure mode):
$ docker push mydockerrepo.org:5000/gcloud The push refers to a repository [mydockerrepo.org:5000/gcloud] unable to ping registry endpoint https://mydockerrepo.org:5000/v0/ v2 ping attempt failed with error: Get https://mydockerrepo.org:5000/v2/: tls: oversized record received with length 20527 v1 ping attempt failed with error: Get https://mydockerrepo.org:5000/v1/_ping: tls: oversized record received with length 20527
NOTE that docker-client is just a proxy between you and the docker engine. So any real config (DOCKER_OPTS) needs to be done on the docker daemon. Where is the docker daemon? Its on the virtualbox (you should see a virtual running with name ‘default’).
So you need to connect to it and update the docker OPTS
~$ docker-machine ssh ## . ## ## ## == ## ## ## ## ## === /"""""""""""""""""\___/ === ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~ \______ o __/ \ \ __/ \____\_______/ _ _ ____ _ _ | |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __ | '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__| | |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ | |_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_| Boot2Docker version 1.10.3, build master : 625117e - Thu Mar 10 22:09:02 UTC 2016 Docker version 1.10.3, build 20f81dd ## EDIT DOCKER CONFIG docker@default:~$ sudo vi /var/lib/boot2docker/profile EXTRA_ARGS=' --label provider=virtualbox --insecure-registry mydockerrepo:5000 ' CTRL-D to exit docker machine $ docker-machine stop $ docker-machine start
All set, now you can use your docker environment in OsX just like you would do in native ubunto. No more docker-quickstart-terminal!!!