1. [Home](<https://delaparra-services.nl/>) 
1. [Knowledge hub](<https://delaparra-services.nl/knowledge-hub>) 
1. [WORKDIR](<https://delaparra-services.nl/knowledge-hub/workdir>)

  

Category: Docker 

# WORKDIR

  Explained by [Reinier de la Parra](<https://delaparra-services.nl/about>)  Updated November 25, 2026    

## What is WORKDIR?

 

WORKDIR: Sets the working directory for subsequent RUN, CMD, COPY, and ENTRYPOINT instructions. Creates it if missing. ` WORKDIR ` sets the working folder for the instructions that follow in a Dockerfile, such as ` RUN `, ` COPY `, ` CMD ` and ` ENTRYPOINT `. ` WORKDIR /var/www/html ` creates the folder if needed and makes it the current directory. It is cleaner than writing ` cd ` inside ` RUN ` commands, which only lasts for that one command, and it makes relative paths in the rest of the Dockerfile predictable.

 

Definition source [Coders Lingo](<https://coderslingo.com/resources/open-dataset/>), [CC BY 4.0](<https://creativecommons.org/licenses/by/4.0/>)

 

## Frequently asked questions about WORKDIR

  

### What should you keep in mind with WORKDIR?

 

Use absolute paths for ` WORKDIR `, and set it once near the top for your application folder. It also determines where you land when you open a shell in the running container with ` docker exec `, which saves typing during debugging. Combined with ` COPY . . `, it keeps a Dockerfile short and easy to follow.

    

### What does an example of WORKDIR look like?

 

```
WORKDIR /usr/src/app
```

 

## At a glance

   CategoryDocker Explained by[Reinier de la Parra](<https://delaparra-services.nl/about>) UpdatedNovember 25, 2026

 

## More Docker terms

 

- [tag](<https://delaparra-services.nl/knowledge-hub/tag>) 
- [tag-and-push](<https://delaparra-services.nl/knowledge-hub/tag-and-push>) 
- [tmpfs](<https://delaparra-services.nl/knowledge-hub/tmpfs>) 
- [USER](<https://delaparra-services.nl/knowledge-hub/user>) 
- [VOLUME](<https://delaparra-services.nl/knowledge-hub/volume>) 
- [volumes (compose)](<https://delaparra-services.nl/knowledge-hub/volumes-compose>)

 

[All terms starting with W](<https://delaparra-services.nl/knowledge-hub#letter-w>)

 

## Skills

 

- ### Docker Build Strategies

 

Use this skill when writing, reviewing, or optimizing Dockerfiles, even if the user just says their image is too large, their build is slow, or they need to harden a container for production. Covers multi-stage builds, layer caching, .dockerignore, non-root users, and image size optimization.

 [View skill](<https://delaparra-services.nl/skills/docker-build-strategies>) [Download zip](<https://delaparra-services.nl/skills/docker-build-strategies/download>) 
- ### Multi Stage Dockerfile

 

'Create optimized multi-stage Dockerfiles for any language or framework'

 [View skill](<https://delaparra-services.nl/skills/multi-stage-dockerfile>) [Download zip](<https://delaparra-services.nl/skills/multi-stage-dockerfile/download>) 
- ### Docker Project Foundations

 

Use this skill when setting up, initializing, or Dockerizing a project, even if the user doesn't explicitly mention Docker but describes a need for containerized local development, adding a database or cache dependency, or running services without host-level installs. Covers Dockerfile, compose.yaml, and .dockerignore creation with Docker best practices.

 [View skill](<https://delaparra-services.nl/skills/docker-project-foundations>) [Download zip](<https://delaparra-services.nl/skills/docker-project-foundations/download>)

 [Download all skills (zip)](<https://delaparra-services.nl/knowledge-hub/workdir/skills.zip>)

 

## Manuals

 

- [Docker for your Laravel app](<https://delaparra-services.nl/manuals/docker-voor-je-laravel-app>)

 

## Related services

 

- [Custom software and web applications](<https://delaparra-services.nl/services#service-03>)

Perhaps your customers need somewhere to download their invoices, or your staff are managing bookings in a spreadsheet.

 

## Need any help?

 

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.

  [Get in touch](<https://delaparra-services.nl/availability>)

[HTML version](https://delaparra-services.nl/knowledge-hub/workdir)
