Ensure Docker WORKDIR values are absolute paths
Error: Docker WORKDIR values are not absolute paths
Bridgecrew Policy ID: BC_DKR_GENERAL_10
Checkov Check ID: CKV_DOCKER_10
Severity: LOW
Docker WORKDIR values are not absolute paths
Description
Using absolute paths for the WORKDIR values in your Dockerfiles can help improve the security and reliability of your builds. The WORKDIR value specifies the working directory for the build stage, and using an absolute path ensures that the correct directory is being used.
By using absolute paths for WORKDIR, you can help prevent potential issues such as using the wrong directory for a stage, which can lead to compatibility problems and potentially compromise the security of your containers. It can also help ensure that your builds are consistent and reliable, as you can easily identify which directory is being used for each stage.
Fix - Buildtime
Docker
FROM alpine:3.5
RUN apk add --update py2-pip
RUN pip install --upgrade pip
WORKDIR /path/to/workdir
WORKDIR /
WORKDIR c:\\windows
WORKDIR "/path/to/workdir"
WORKDIR "c:\\windows"
ENV DIRPATH=/path
ENV GLASSFISH_ARCHIVE glassfish5
WORKDIR $DIRPATH/$DIRNAME
WORKDIR ${GLASSFISH_HOME}/bin
COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r /usr/src/app/requirements.txt
COPY app.py /usr/src/app/
COPY templates/index.html /usr/src/app/templates/
EXPOSE 5000
CMD ["python", "/usr/src/app/app.py"]
Updated 7 months ago