build context for docker image very large

I have created a couple different directories on my host machine as I try to learn about Docker just to keep my dockerfiles organized. My Dockerfile I just ran looks like this:

FROM crystal/centos
MAINTAINER crystal

ADD ./rpms/test.rpm ./rpms/ 
RUN yum -y --nogpgcheck localinstall /rpms/test.rpm 

My actual rpm is only 1 GB. But when I try to do sudo docker build -t="crystal/test" ., I get sending build context to Docker daemon 3.5 GB. Is there something else that I’m unaware of as you continue to build Docker images? Is my memory accumulating as I build more images in my other directories on my host machine?

  • Docker Add every file in current directory
  • Running Nodejs Application in Amazon EC2 to serve my static content in nodejs using nginx as a reverse proxy
  • How can I tell in Dockerfile which comand I want to execute when input “docker run” command?
  • How to set up WebStorm with Docker debug configurations?
  • docker-compose run with isolated sets of services?
  • Modifying golang Docker Container using the running shell
  • How to deliver dockerized app to client?
  • Launch service at container startup
  • Docker yum install issue - Cannot retrieve metalink for repository: epel/x86_64
  • Passing parameter in docker build command with fish
  • Symfony2 app always has a 3 second wait between kernel.request and kernel.controller
  • How do i make this non-interactive?
  • 3 Solutions collect form web for “build context for docker image very large”

    The Docker client sends the entire “build context” to the Docker daemon. That build context (by default) is the entire directory the Dockerfile is in (so, the entire rpms tree).

    You can setup a .dockerignore file to get Docker to ignore some files. You might want to experiment with it.

    Alternatively, you can move your rpms folder one directory level above your Dockerfile, and only symlink test.rpm into the Dockerfile‘s directory.

    I fixed it by moving my Dockerfile and docker-compose.yml into a subfolder and it worked great. Apparently docker sends the current folder to the daemon and my folder was 9 gigs.

    In my case that was when i execute with wrong -f arguments – without path to directory where located Dockerfile

    docker build --no-cache -t nginx5 -f /home/DF/Dockerfile /home/DF/ – right

    docker build --no-cache -t nginx5 -f /home/DF/Dockerfile – wrong

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.