WORKDIR
The Dockerfile instruction that sets the folder later instructions and the container start in.
In more detail
WORKDIR /app creates the folder if needed and makes relative paths in COPY, RUN, CMD and ENTRYPOINT resolve from there. Prefer it over RUN cd /app, which only lasts for that one RUN.
Examples
WORKDIR /appWORKDIR /srcWORKDIR /workspaceRelated terms
- Dockerfile — A text file of instructions, such as FROM, COPY and RUN, that tells Docker how to build an image.
- COPY — The Dockerfile instruction that copies files from the build context into the image.
Taught in
- Building and Pushing Container Images — Continuous Integration & Continuous Delivery Pipelines
- Container Images The Exam Way — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Pull And Inspect A Third Party Image — Docker Architecture & Production Containers
- Run The Spine Service And Publish Its Port — Docker Architecture & Production Containers
- Build Context, Dockerignore And Your First Dockerfile — Docker Architecture & Production Containers
- FROM, WORKDIR, COPY And ADD — Docker Architecture & Production Containers
- Shipping in Scratch and Distroless Images — Concurrent Systems Programming with Go
- Packaging Into A Container — Modern Java: Virtual Threads & High-Throughput Services
- Twelve Lines, Ten Warnings: Dockerfile Instructions And hadolint — Docker Certified Associate (DCA) Exam Prep
- One Edited File, Six Rebuilt Steps: Layers, Cache And Flat Images — Docker Certified Associate (DCA) Exam Prep
- Two Containers, How Much Disk? Storage Drivers, Layers And devicemapper — Docker Certified Associate (DCA) Exam Prep