I wanted copy /root/master directory in /var/ like this : cp -R /root/master /var/
However, I had the following error : COPY failed: file not found in build context or excluded by .dockerignore
I found the solution on Stackoverflow :
The <src> path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.
In fact, I needed to copy the master directory in a Docker sub folder because I used a docker-compose.yml with services:
services:
master:
container_name: master
env_file:
- variables.env
build:
context: ./subdirectory1/
dockerfile: Dockerfile
args:
subdirectory1/
DockerFile
subdirectory2
DockerFile
So in your DockerFile, add the following :
WORKDIR /var
COPY ./master .
COPY ./master/ .