turnbullpress / dockerbook-code

The code and configuration examples from The Docker Book (http://www.dockerbook.com)
927 stars 581 forks source link

the correct .dockerignore / loading of context #6

Closed dreamineering closed 9 years ago

dreamineering commented 9 years ago

Hi James,

I am making a mistake somewhere I don't understand and perhaps there is a valuable lesson to be taught in book as while investigating this issue I have noticed it is quite common for .dockerignore to trip up newcomers.

I have been trying out installs on different machines trying to get the docker flow down using identical code base for practice

And with an initial build I found the follow problem with uploading the build context.

machine one - problem build see the large context 747 MB (box had previously built other images and containers)

vagrant@vagrant-ubuntu-trusty-64:/host/services/src$ docker build -t drmg/services . Uploading context 747 MB Uploading context Step 0 : FROM dockerfile/nodejs Pulling repository dockerfile/nodejs 2014/11/01 16:33:39 Get https://index.docker.io/v1/repositories/dockerfile/nodejs/images: dial tcp: lookup index.docker.io on 10.0.2.3:53: no answer from server vagrant@vagrant-ubuntu-trusty-64:/host/services/src$ docker build -t drmg/services . ^Cvagrant@vagrant-ubuntu-trusty-64:/host/services/src$ sudo docker build -t drmg/services .

machine two - no problems only 575 kB on a fresh install

vagrant@ubuntu:src master % sudo docker build -t drmg/backend . Sending build context to Docker daemon 575 kB Sending build context to Docker daemon Step 0 : FROM dockerfile/nodejs Pulling repository dockerfile/nodejs 9a76e1635147: Pulling dependent layers

This is not the first time this has happened as was performing builds fine the other day with fig then got where nothing was happening. I ended up thinking the problem was with fig so switched to specifically building an image first then referencing that image in fig.

The only difference in machines was that on machine one I had followed through the following tutorial prior to the build so there were a few images already on the system. While machine two was completely fresh.

https://github.com/nearform/nscale/wiki/Vagrant-Rapid-Start-Guide

I think I am doing something wrong with dockerfile and fig.yml and should be loading source in fig.yml but still don't understand why the sizes of context should be different?

You can find the Dockerfile, fig and .dockerignore here

https://github.com/stackmates/common.services/tree/master/src

I have not been as attentive to setup as I could have been but attempting to be more thorough to describe each step I take with building boxes below to try to uncover the exact circumstance of how and when this happens.

https://github.com/stackmates/stackmates/tree/master/boxes

Best regards

Matt

jamtur01 commented 9 years ago

The only thing pulled in via the build context should be the contents of the directory (and it's subdirectories) you're running docker build from, i.e. if you have a 500Mb file in one build directory and not in another you'll see a difference. If that isn't the case you're seeing a bug.

Can you check what's in each directory on each host?

dreamineering commented 9 years ago

It is exactly same I referencing code from virtual drive on my mac

dreamineering commented 9 years ago

My intuition is that this has occurred after previously building a few images & containers, logging out of virtual machine and then sshing back in.

Is there a policy that should be adopted before doing that? Ie should I be stopping all containers prior to logging out / closing a machine?

dreamineering commented 9 years ago

In vagrant I was referencing common codebase

config.vm.synced_folder "../../stackmates", "/stackmates"

and then running through a process I had been writing in an attempt to prove consistent results.

jamtur01 commented 9 years ago

I think this (was) a Docker bug. Sorry about the delay I missed your responses. Are you still having an issue?

jamtur01 commented 9 years ago

Please re-open if you're having problems.