Using command prompt to connecting to docker toolbox running on a Window Host

I am trying to automate my container images using script. The GoLang SDK (Docker Engine API) helps but only if i can get into docker shell. So how do I do it?

Create a docker machine and then gain access to docker ssh. From there, we can execute any scripts we wants.

a) Create a docker machine called "default " - If you already have one, please use this one. :)

  docker-machine create --driver virtualbox autodocker

b) Executing docker command from Dos Command via docker-machine.

docker-machine ssh default "docker run hello-world"

This will execute docker command to download an image called 'hello-world'.

Longer way to do it.

First you run

1. docker-machine.exe env --shell cmd default

2. It gives me alot of info as shown below :-

SET DOCKER_CERT_PATH=C:\Users\User\.docker\machine\machines\default
REM Run this command to configure your shell:
REM     @FOR /f "tokens=*" %i IN ('docker-machine.exe env --shell cmd default') DO @%i

3. set DOCKER_MACHINE_NAME=default

If you look at the bold text above, copy and paste that in your DOS command and you can just type

4. @FOR /f "tokens=*" %i IN ('docker-machine.exe env --shell cmd default') DO @%i

Then from command prompt just run :-

docker run hello-world.

Walla!!! that's it. :)


Popular posts from this blog

ionic2 cordova build android - Unable resolve gradle 2.2.3

A quick tutorial for OWASP ZAP tool for beginners