1

I have docker running on a windows box successfully. When I try to docker build . an image, docker downloads a lot of large image files in step 1.I have no problem with this. However, the last time I tried, I got an unexpected interruption when all but one image file was remaining to download.
When I built again, all the downloads started afresh and this has happened again and again. My question is, does docker not cache the already downloaded files somewhere or is there not a way to avoid this repetitive download?
Here is my Dockerfile

# Dockerfile
FROM ingensi/play-framework
COPY activator.sh /activator.sh
EXPOSE 8000
RUN mkdir /app
WORKDIR /app
CMD ["activator","run"]

This is the console output on running docker build .

Sending build context to Docker daemon 7.543 MB
Step 1 : FROM ingensi/play-framework
latest: Pulling from ingensi/play-framework
a3ed95caeb02: Pull complete
6b8936f53711: Downloading 10.77 MB/77.28 MB
ba9b63c22e85: Downloading 8.222 MB/18.17 MB
c8f760722057: Download complete
05c3b10b9cd9: Waiting
eea97537ef12: Waiting
40254e2b433f: Waiting
66be6357e6af: Waiting
ca0f372c20c8: Waiting
1f9b623e6354: Waiting

The image files being downloaded are always the same and appear in the same order judging by the codes on the left and file sizes.

egimaben
  • 653
  • 7
  • 22

2 Answers2

1

It's unclear what part of your Dockerfile would cause files to download. Note that Docker will cache image layers, not files that are downloaded to create layers. Details on how to take advantage of that are here: https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/build-cache

friism
  • 19,068
  • 5
  • 80
  • 116
  • I have added console output to clear this up. Am just going to check the link but are you saying that docker needed the whole download to complete before it can cache a reusable image layer? – egimaben Sep 18 '16 at 09:56
0

When I built again, all the downloads started afresh and this has happened again and again.

My question is, does docker not cache the already downloaded files somewhere?

Yes, images are stored in a cache folder.
See "Where are docker images stored on the host machine?"

In your case, you might use Docker for Windows which requires Microsoft Hyper-V to run.
There are caching issue, but only for Docker cloud, not locally.

I advised in the comment:

docker-machine ssh
cd /C/Users/<yourLogin>/path/to/your/project
docker build
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I checked the SO link for where images are stored. The only folders I have under `%USERPROFILE%` are `.VirtualBox` which contains only log files and `.docker/machine` which contains `cache`, `machines` and `certs` folders. So I guess my guy should be `cache` which only has `boot2docker.iso` and `boot2docker.iso.tmpxxxx`. There is no sign of my already downloaded images. May be am looking in the wrong place. Given am running locally, hence no caching issues, my confusion remains, if there is a cache can't docker pick up from where it left off like other tools do when I run the same command? – egimaben Sep 18 '16 at 09:52
  • @egima What version of docker are you using? On which OS? If Windows 10, are you using HyperV? – VonC Sep 18 '16 at 09:53
  • am using docker 1.12.0 build 8eab29e on windows 8.1. I followed the instructions on the docker official [link](https://docs.docker.com/v1.8/installation/windows/) to install. – egimaben Sep 18 '16 at 10:11
  • @egima so that should be the virtualbox edition. Maybe there is a right issue? Are you running docker build from an ssh session in the docker machine VM? – VonC Sep 18 '16 at 10:31
  • 1
    @egima Try instead a `docker-machine ssh` in an environment similar to http://stackoverflow.com/a/36787274/6309 – VonC Sep 18 '16 at 12:02
  • after following the instructions, I now have the command prompt switched to `docker@test:~$`. Remember mine is not even an error but how to reuse already downloaded images and avoid everything downloading afresh everytime i run `docker build .` – egimaben Sep 19 '16 at 07:21
  • @egima Sure: what happen when you do a docker build within that new session? – VonC Sep 19 '16 at 07:22
  • it's definitely not seing my project from this context i.e. Dockerfile is absent. Does this mean I have to set up my project afresh after sshing into this VM? – egimaben Sep 19 '16 at 08:12
  • 1
    @egima you need to go to `/C/Users//path/to/your/project`: that folder is automatically shared by VirtualBox. If your project is in there, docker will see it. – VonC Sep 19 '16 at 08:13
  • running my commands after sshing into a VM has solved my problem thanks a ton for your steps. Now I can't pick a file from the shared paths while performing the build. I can't even `ls` or `cp` because within the build process, the directories are not being seen. I guess that deserves another question. – egimaben Sep 20 '16 at 07:00
  • @egima Yes, it does. Don't forget to mark this one as completed (http://stackoverflow.com/help/accepted-answer) – VonC Sep 20 '16 at 07:02
  • done. Checkout this http://stackoverflow.com/questions/39589006/windows-c-users-username-directories-not-visible-during-docker-build-com – egimaben Sep 20 '16 at 08:23