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

  • Goal: to use the same script cv.sh 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'
services:
  cv_driver:
    build:
      context: .
      dockerfile: .cv/cv_driver/Dockerfile.template
    privileged: true
    restart: always
  • My Repo looks like this
├── cv
│   ├── cv.sh
│   ├── 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'
services:
  cv_driver:
    build: cv/cv_driver/Dockerfile.template
    privileged: true
    restart: always

Laurent

1 Like

Hello,

This is not supported yet, but we are working on it: https://github.com/resin-io/resin-builder/issues/420

Wrong url in my last message, sorry: https://github.com/resin-io-modules/resin-multibuild/issues/19

Okay, thanks for clarifying.

looking foreward to seeing this implemented :slight_smile:

1 Like

@zvin

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:

test:
build:
context: …/
dockerfile: docker/cli/Dockerfile

I hope this helps…

1 Like

Hai,
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
Thanks,
Riya.
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

Is there any update on this capability from your side?

@Tschebbischeff as it happens I’ve just put up a PR which leads the way for this to be used on both our cloud servers and local builds.

The delay came from the fact that we needed large architectural changes in our build pipeline to be able to support. The ball is well and truly rolling though, so I don’t imagine it should be too long until this is available.

You can track the progress of this PR here: https://github.com/balena-io-modules/resin-bundle-resolve/pull/27

Note that there is more work in integrating the results of this into our build system, so even once this PR is merged, you won’t see this feature in production immediately.

1 Like

Thank you very much for your update and work on this, we are looking forward to seeing it implemented :slight_smile:

Greetings, Tarek

So version v2.29.0+rev1 does not yet support the compose context and dockerfile options. The PR was closed 21 days ago and the latest balenaOS version was released 22 days ago :frowning:

We will keep you posted on when this gets released :slight_smile:

After testing again it seems the context keyword is still not supported.
Sadly balena push does not support specifying a compose file which would give us the flexibility to maintain two version depending on the desired deployment target.

Hi @bnjmn83 the OS version is irrelevant for this change, the changes are not going in there.

The https://github.com/balena-io-modules/resin-bundle-resolve/pull/27 is a component that goes into other components, as mentioned in the PR, that is the CLI mainly, where the changes are not merged yet, that’s what we mentioned that we’ll keep you posted as it is released. Please bear with us.

OK thanks for getting back to me. Any clue of the time window we are talking about?

Checking with the team, I think there are multiple changes that need to coordinate, and that takes some effort, but we are working on it.