Docker development workflow¶
A Docker development workflow involves using containers to standardize and isolate the development environment, ensuring that code runs consistently across different machines^[docker.md]. This approach allows developers to work inside a containerized environment rather than relying on a local installation of dependencies.
Containerized Development Cycle¶
The workflow typically begins with defining the environment in a Dockerfile and then building an image.^[docker.md]
- Build Image: Construct the Docker image using a specific target stage (often labeled as
dev) to include necessary compilation tools and SDKs.^[docker.md] - Run and Mount: Execute the container interactively and mount the current project directory from the host machine into the container's workspace.^[docker.md]
For example, after building a Go development image, you can run a shell session inside the container while keeping your source code synchronized between the host and the container via a volume mount (-v ${PWD}:/work).^[docker.md]
Example Workflow (Go)¶
The following commands illustrate a typical workflow for developing a Go application inside a container^[docker.md]:
# Build the development target image
docker build --target dev . -t yudady/golang:1.18
# Run container interactively, mounting current directory
docker run -it -v ${PWD}:/work yudady/golang:1.18 sh
# Verify environment inside container
go version
Related Concepts¶
- CI/CD Pipelines
- [[Containerization]]
Sources¶
^[docker.md]