Skip to content

Docker WORKDIR values are not absolute paths

Description

This rule detects whether all WORKDIR values specified in Dockerfiles are absolute paths. Absolute paths prevent ambiguity, ensure correct directory navigate to the intended directory structure, and contribute to predictable behavior during image build and runtime. Therefore, we recommend always using absolute paths for WORKDIR instruction in Dockerfiles.

Code Example

dockerfile
- WORKDIR relative/path
+ WORKDIR /absolute/path

Remediation

Docker

To mitigate this issue, ensure that all WORKDIR instructions in your Dockerfile use absolute paths.

Example:

Rule Details

FieldValue
IDIAC-0843
SeverityLOW
IaC Typedockerfile
FrameworksDocker
Checkov IDCKV_DOCKER_10

References