Skip to content

Update "RUN Instruction Using 'cd' Instead of WORKDIR" query for Docker, allow cd when not at the beginning #5116

@malte-laukoetter

Description

@malte-laukoetter

Platform

Docker

Query

f4a6bcd3-e231-4acf-993c-aa027be50d2e

Description

In long RUN commands there sometimes exists cds in the middle of the Instruction to change a directory. It is not helpful to replace such a cd with a WORKDIR instruction as this would create an additional layer. Therefore only cds that are at the beginning of a RUN instruction should be reported.

Example

The official docker image for fluentd uses such a construct in the Dockerfile for its debian image: https://github.com/fluent/fluentd-docker-image/blob/a9e4cee765c7aaf7876d6fe3282aa565dbcdc2a4/v1.14/debian/Dockerfile

Metadata

Metadata

Labels

communityCommunity contributionqueryNew query feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions