2

When I run the command:

docker run dockerinaction/hello_world

The first time the following scenario plays out:

enter image description here

The dockerinaction/hello_world Dockerfile can be seen below:

FROM busybox:latest
CMD ["echo", "hello world"]

So from the wording:

Docker searches Docker Hub for the image

There are several things I'm curious about:

  • Is the image dockerinaction/hello_world?
  • Does this image reference another image named busybox:latest?
  • What about the Dockerfile is that on my machine somewhere?
mbigras
  • 7,664
  • 11
  • 50
  • 111
  • 1
    I think a docker image does not include the Dockerfile that built it. But it does refer to the image it is based on. http://stackoverflow.com/questions/25583038/docker-image-format – Thilo Feb 26 '17 at 01:33

1 Answers1

5

Answers to each bulleted question, in corresponding order:

  • Yes, the image is dockerinaction/hello_world.
  • Yes, the image does reference busybox:latest, and builds upon it.
  • No, the Dockerfile is not stored on your machine. The docker run command is downloading a compressed version of the built Docker image that it found on Docker Hub. In some ways, you can think of the Dockerfile as the source code and the built image as the binary.

If you wanted to, you could write your own Dockerfile with the following contents:

FROM busybox:latest
CMD ["echo", "hello world"]

Then, in the directory containing that file (named Dockerfile), you could:

$ docker build -t my-hello-world:latest .
$ docker run my-hello-world:latest

The docker build command builds the Dockerfile, which in this case is stored on your machine. The built Docker image is tagged as my-hello-world:latest, and is only available on your machine (where it was built) unless you push it somewhere. You can run the built image from your machine by referring to the tag in the docker run command, as in the second line above.

mkasberg
  • 16,022
  • 3
  • 42
  • 46