Docker development container workflow¶
The Docker development container workflow allows developers to compile and run code inside an isolated container environment rather than on the local host machine.^[400-devops-03-containerization-docker.md] This practice typically involves creating a dedicated image specifically for development tasks, often referred to as a dev target.^[400-devops-03-containerization-docker.md]
Image Configuration¶
To support this workflow, the Dockerfile is structured with multiple stages, explicitly defining a stage for development.^[400-devops-03-containerization-docker.md] For example, a configuration might use a golang:1.18-alpine base image aliased as dev to set up the working directory and necessary build tools.^[400-devops-03-containerization-docker.md] This separation distinguishes the build environment from the final runtime environment.^[400-devops-03-containerization-docker.md]
Execution Process¶
Once the development image is built, the workflow involves running a container that mounts the current project directory from the host machine into the container.^[400-devops-03-containerization-docker.md] This is achieved using the -v flag to map the current working directory (e.g., ${PWD}) to a path inside the container (e.g., /work).^[400-devops-03-containerization-docker.md] This setup allows files edited on the host to be immediately available inside the container for execution or compilation.^[400-devops-03-containerization-docker.md]
Related Concepts¶
- [[Docker]]
- CI/CD Pipeline
Sources¶
- 400-devops-03-containerization-docker.md