Using WORKDIR Instruction in Dockerfile
📖 Scenario: You are creating a Docker image for a simple web application. You want to organize your files inside the container by setting a working directory.
🎯 Goal: Learn how to use the WORKDIR instruction in a Dockerfile to set the working directory for subsequent commands.
📋 What You'll Learn
Create a Dockerfile with a base image
Set a working directory using
WORKDIRAdd a file inside the working directory
Print the current working directory inside the container
💡 Why This Matters
🌍 Real World
Setting a working directory in Docker images is common to keep files organized and commands simple.
💼 Career
Understanding <code>WORKDIR</code> is essential for writing clean Dockerfiles used in software development and deployment.
Progress0 / 4 steps