What is the purpose of the WORKDIR instruction in a Dockerfile?

Docker Fundamentals Medium

Docker Fundamentals — Medium

What is the purpose of the WORKDIR instruction in a Dockerfile?

Key points

  • WORKDIR is used to define the working directory inside the Docker image
  • It is crucial for executing commands in the right context
  • WORKDIR does not affect the host machine's directory
  • It simplifies file path management within the container

Ready to go further?

Related questions