1
version: '3'
services:
  nginx:
    image: nginxtest
    container_name: nginxtest-container
    volumes:
      - "$PWD:/apps"
    ports:
      - "80:80"

Above is my compose file.

I have created dummy file in that directory. If I want to ignore or exclude changes made in one file and all other files should be reflecting the change as it is, how to do that.

grapes
  • 8,185
  • 1
  • 19
  • 31
  • 1
    Possible duplicate of [Add a volume to Docker, but exclude a sub-folder](https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder) – David Maze Feb 15 '19 at 14:27

1 Answers1

0

Let's say you want to mount $PWD but want to exclude $PWD/template, you can use this.

version: '3'
services:
  nginx:
    image: nginx
    container_name: nginxtest-container
    volumes:
      -  "/apps/template"
      - "$PWD:/apps"
    ports:
      - "80:80"

/apps/template creates a separate space. Anything in $PWD/template will not be mirrored in the container, anything in /apps/template will also not be reflected on the host.

Siyu
  • 11,187
  • 4
  • 43
  • 55
  • thanks ,this works when template is a folder , file inside template will not be reflected to the container but if i want to ignore a file let consider template is a file ,what to do then ..? – Prashant Jha Feb 16 '19 at 16:53