Defining context in docker compose - Error: Cannot locate specified Dockerfile: Dockerfile


  • Goal: to use the same script for multiple containers i’m deploying
  • Problem:
    [Info]       Building on arm02
    [Info]       Pulling previous images for caching purposes...
    [Success]    Successfully pulled cache images
    [Error]      Some services failed to build:
    [Error]        Service: cv_driver
    [Error]          Error: Cannot locate specified Dockerfile: Dockerfile
    [Error]      Not deploying release.
  • My docker-compose.yml File looks the following:
version: '2'
      context: .
      dockerfile: .cv/cv_driver/Dockerfile.template
    privileged: true
    restart: always
  • My Repo looks like this
β”œβ”€β”€ cv
β”‚   β”œβ”€β”€
β”‚   β”œβ”€β”€ cv_driver
β”‚   β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”‚   └── Dockerfile.template
β”‚   β”œβ”€β”€ cv_logic
β”‚   β”‚   └── Dockerfile.template
└── docker-compose.yml

I tried it with referencing to cd_driver folder, the cv_driver/Dockerfile and cv_driver/Dockerfile.template


Have you tried simplifying the build directive?

version: '2'
    build: cv/cv_driver/Dockerfile.template
    privileged: true
    restart: always




This is not supported yet, but we are working on it:


Wrong url in my last message, sorry:


Okay, thanks for clarifying.

looking foreward to seeing this implemented :slight_smile:



is there an update on this issue? or any information on when it might be integrated?


Hello zagatta-sonah,

Sorry I don’t have any update on this issue yet.


Hello zvin,

I just wanted to give this another push, I know it’s not yet in from the PR.

I really hope we do see this feature soon, though, sharing code between containers is a pain right now :stuck_out_tongue:

Have a great day and thanks for your efforts.

Greetings, Tarek


Hi, When you define a context in docker-compose, the dockerfile: bit is relative to that context. So the proper configuration would be:

context: …/
dockerfile: docker/cli/Dockerfile

I hope this helps…


Can u Please try this when Composing the Context in Docker file, the file should be located.
$ tree
β”œβ”€β”€ build
β”‚ └── etc.txt
β”œβ”€β”€ dockerfile
β”‚ └── Dockerfile.test
└── tools
└── docker
└── docker-compose.yml
Docker Composer


Hello @azharuddin , Hello @riyawilliams ,

I’m afraid the original question takes realtive paths into account.
The build context is specified as β€œ.” with the dockerfile specified relative to . as β€œ./cv/cv_driver/Dockerfile.template”. Building with these arguments however ignores the container completely.

I’m sorry but I think I don’t quite understand your example @riyawilliams . I know how it should work in principle. e.g the docker-compose.yml in your example should have a build context of β€œ.” and a dockerfile of β€œ./dockerfile/Dockerfile.test” but this won’t currently work in a multicontainer setup. It just ignores the container with those settings completely.

Edit: @lv82 Using the build directive like that works, yes, but you have no access to files and folders from the top level (the level at which the docker-compose resides) from the inside of the specified Dockerfile, because the context will be the parent directory of the Dockerfile, not the docker-compose.
(Actually this is our current approach, we would just like to load some folders from the top level from multiple Dockerfiles residing within some subfolders)

Greetings, Tarek