title: Docker-compose and .dockerignore
body: <p>There is small config of docker-compose with Dockerfiles and .dockerignore files I have in subdirectories. I can't understand why my images after build include everything even I have some items to ignore in .dockerignore. Here is what I have</p>
  <pre><code>docker-compose.yml
  docker
  ├── app
  │   ├── Dockerfile
  │   └── .dockerignore
  └── web
      ├── Dockerfile
      ├── nginx.conf
      └── .dockerignore
  </code></pre>
  <p>Example of .dockerignore:</p>
  <pre><code>**/.dockerignore
  docker-compose.yml
  log
  **/log
  ../../log
  </code></pre>
  <p>I just run this as follows:</p>
  <pre><code>docker-compose up -d --build --no-cache
  </code></pre>
  <p>None of the above ignored.. What am I doing wrong?</p>
  <pre><code>docker-compose version 1.23.2, build 1110ad01
  </code></pre>
  <p>Adding Dockerfile for the app service (see docker-compose). Docker-compose packs two images with ROR app and nginx. For both dockerfiles I have dockerignore. So my understanding is that I can say what exactly I want in each. But it is not. How can I ignore some of the files in package? Or should I put my Dockerfile and dockerignore in different paths since build works only inside the context.. I am confused.</p>
  <pre><code>FROM ruby:2.4.1
  RUN apt-get update -qq &amp;&amp; apt-get install -y build-essential libpq-dev nodejs imagemagick
  # Configuring main directory
  RUN mkdir -p /var/www/example.com
  WORKDIR /var/www/example.com
  # Setting env up
  ENV RAILS_ENV='production'
  ENV RACK_ENV='production'
  
  # Adding gems
  COPY Gemfile Gemfile
  COPY Gemfile.lock Gemfile.lock
  RUN bundle install --jobs 20 --retry 5 --without development test
  # Adding project files
  COPY . .
  
  EXPOSE 3000
  CMD [&quot;bundle&quot;, &quot;exec&quot;, &quot;puma&quot;, &quot;-C&quot;, &quot;config/puma.rb&quot;]
  </code></pre>
  <p>So I thought that <code>COPY . . </code> checks .dockerignore first.. no?</p>