Running Docker from Windows CMD prompt

Neil Avery
1 min readNov 30, 2016

--

I’m working on a secret project that will be published in a few posts time. It uses microservices and docker and not much else. When downloading the Docker toolbox I tried to run:

CMD> docker run hello-world

boom!> docker: An error occurred trying to connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/create: open
./pipe/docker_engine: The system cannot find the file specified..
See ‘docker run — help’.

Not good! — Lets try something simple

CMD> docker ps

An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json: open //./pipe/dock
er_engine: The system cannot find the file specified.

Looks like my env is broken…. to fix I needed to do the following:

  1. CMD>docker-machine env default
    SET DOCKER_TLS_VERIFY=1
    SET DOCKER_HOST=tcp://192.168.99.100:2376
    SET DOCKER_CERT_PATH= C:\.docker\machine\machines\de
    SET DOCKER_MACHINE_NAME=default
    REM Run this command to configure your shell:
    REM @FOR /f “tokens=*” %i IN (‘docker-machine env default’) DO

2. Then grab the ‘REM’ tail end of the output and past it in to apply
CMD > @FOR /f “tokens=*” %i IN (‘docker-machine env default’) DO IDEO

3. Test again — winner
CMD> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

4. Lets try docker run again
CMD>docker run hello-world
Unable to find image ‘hello-world:latest’ locally latest: Pulling from library/hello-world
c04b14da8d14: Pull complete
Digest:sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.
etc

Yay — it works!

… time for some real work …

--

--

Neil Avery

@Liquidlabs, ex Confluent, CTO-Excelian, Thoughtworks. Founder Logscape, Startups, code-monkey, songwriter tennis-nut, snowboarding-nut, and Dad!