Weird docker-compose caching issue

Hi,

I’ve got a really weird caching issue.

Deleting all cached files (or did I?) and using docker-compse run to create and run a new build starts an old image instead of the freshly built one.

TL;DR

My old Dockerfile looked like this:

FROM node:8-alpine

# allow node to bind port 80 regardless of uid
RUN apk add --update-cache libcap git && setcap cap_net_bind_service=+ep /usr/local/bin/node

# configure
LABEL maintainer="sevenval.com"
WORKDIR /usr/local/opt/backend/
ENTRYPOINT ["yarn"]
CMD ["start"]
EXPOSE 80
ARG GIT_COMMIT=

# add config file
COPY ["config", "./config"]

# add configs
COPY ["package.json", "yarn.lock", ".npmrc", "tsconfig.json", "tslint.json", "./"]
# install dependencies
RUN yarn install

# add src
COPY ["src", "./src"]

# set git version and invalidate docker cache
ENV GIT_COMMIT=$GIT_COMMIT

# build
RUN yarn run build

My new Dockerfile looks like this:

FROM node:8-alpine

# allow node to bind port 80 regardless of uid
RUN apk add --update-cache libcap git && setcap cap_net_bind_service=+ep /usr/local/bin/node

# configure
LABEL maintainer="sevenval.com"
WORKDIR /usr/local/opt/backend/
ENTRYPOINT ["yarn"]
CMD ["start"]
EXPOSE 80
ARG GIT_COMMIT=
ARG NODE_ENV
ARG SERVICE_NAME

# add config file
COPY ["config/default.js", "config/"]
COPY ["config/$NODE_ENV.js", "config/"]

# add configs
COPY ["package.json", "yarn.lock", ".npmrc", "tsconfig.json", "tslint.json", "./"]

# install dependencies
RUN yarn install $([ "$NODE_ENV" != 'test' ] && echo --production)

# add src
COPY ["src", "./src"]

# set persistent ENV vars version and invalidate docker cache
ENV GIT_COMMIT=$GIT_COMMIT
ENV NODE_ENV=$NODE_ENV
ENV SERVICE_NAME=$SERVICE_NAME

# build or test
RUN yarn run build

RUN ls config

and my docker-compose.yml changed from this:

version: "3.1"

services:

  test:
    build:
      context: "."
    command: ["mocha"]
    environment:
      NODE_ENV: "test"
      APP_DOMAIN: "localhost"
      EMAIL_DOMAIN: "localhost"
      APP_START: "false"
    networks:
      - service-account-testing
    restart: "no"
    volumes:
      - ./:/usr/local/opt/backend/
      - ./logs:/var/log/
    secrets:
      - jwt.key
      - db.key
      - superuser.key

secrets:
  jwt.key:
    file: ./jwt.key
  db.key:
    file: ./db.key
  superuser.key:
    file: ./superuser.key
networks:
  service-account-testing:

to this:

version: "3.1"

services:

  test:
    build:
      context: "."
      dockerfile: deployment/Dockerfile
      args:
        NODE_ENV: test
        SERVICE_NAME: service-account
    command: ["mocha"]
    environment:
      APP_START: "false"
    networks:
      - service-account-testing
    restart: "no"
    volumes:
      - ./:/usr/local/opt/backend/
      - ./logs:/var/log/
    secrets:
      - jwt.key
      - db.key
      - superuser.key

secrets:
  jwt.key:
    file: ./jwt.key
  db.key:
    file: ./db.key
  superuser.key:
    file: ./superuser.key
networks:
  service-account-testing:

now deleting assumingl everyhting from all caches

docker-compose down --rmi all
docker-compose rm -f
docker kill $(docker ps -q)
docker rmi $(docker images -q)
docker system prune -a
docker system prune -a --volumes

and then bringing it up again with:
docker-compose run --rm --no-deps --entrypoint=/bin/sh test

shows that during the build step the correct 2 files reside in config
but running
ls config
shows that this is still an old build containing the whole config folder (3+ files)

Running:
docker run --rm -ti --entrypoint=/bin/sh 6133cceac701
with the id from the docker-compose build output runs the correct version with the correct number (and content) of config files

where does docker-compose keep this cached???

Thanks in advance,
fred

Edit:

$ docker-compose -v
docker-compose version 1.13.0, build 1719ceb
$ docker -v
Docker version 17.12.1-ce, build 7390fc6

I found it, I mounted the local dir over the appropriate folder in the docker-compose.yml

it’s sovled