docs icon indicating copy to clipboard operation
docs copied to clipboard

Possible ambiguity about which directory the path to the Dockerfile is relative to

Open ekoka opened this issue 1 year ago • 2 comments
trafficstars

Is this a docs issue?

  • [X] My issue is about the documentation content or website

Type of issue

Other

Description

Early in the document, there's this paragraph which indicates that the specified Dockerfile location is relative to the Compose file's parent dir.

In the latter case, build arguments can be specified, including an alternate Dockerfile location. The path can be absolute or relative. If it is relative, it is resolved from the Compose file's parent folder. If it is absolute, the path prevents the Compose file from being portable so Compose displays a warning.

Then later there's this example and its explanation that create a bit of confusion.

  backend:
    image: example/database
    build:
      context: backend
      dockerfile: ../backend.Dockerfile

example/database: A Docker image is built using backend sub-directory within the Compose file parent folder. backend.Dockerfile file is used to define build steps, this file is searched relative to the context path, which means .. resolves to the Compose file's parent folder, so backend.Dockerfile is a sibling file.

It's not clear what the rule is. Is the Dockerfile searched relative to the specified context or to the compose file's parent directory?

Location

https://docs.docker.com/compose/compose-file/build/

Suggestion

Provide clarity as to whether the Dockerfile is relative to the Compose file's parent directory or to the specified context directory.

ekoka avatar Mar 22 '24 03:03 ekoka

Upon further inspection, it seems that dockerfile is relative to the build context. This is specified in the Atrributes > dockerfile subsection of the document.

dockerfile sets an alternate Dockerfile. A relative path is resolved from the build context. Compose warns you about the absolute path used to define the Dockerfile as it prevents Compose files from being portable.

ekoka avatar Mar 22 '24 09:03 ekoka

There hasn't been any activity on this issue for a long time. If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment. If not, this issue will be closed in 14 days. This helps our maintainers focus on the active issues.

Prevent issues from auto-closing with a /lifecycle frozen comment.

/lifecycle stale

docker-robot[bot] avatar Jun 25 '24 01:06 docker-robot[bot]

Closed issues are locked after 30 days of inactivity. This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

/lifecycle locked

docker-robot[bot] avatar Aug 08 '24 03:08 docker-robot[bot]