What Is New in Docker Engine 17.05
Docker 17.05 CE introduces significant enhancements focused on the developer workflow, particularly around multi-stage builds and the underlying buildkit technology. This release marks a shift towards more efficient and secure image building processes.
| Category | Key Changes |
|---|---|
| New Features | Multi-stage Builds, docker stack deploy for compose files |
| Improvements | BuildKit backend (experimental), docker system commands |
| Runtime & Orchestration | Swarm mode service logs, service rolling updates |
| Deprecations | Shortened image ID prefixes, --api-enable-cors flag |
How do multi-stage builds change Dockerfile design?
Multi-stage builds are the headline feature, allowing you to use multiple FROM statements in a single Dockerfile. This lets you separate your build-time dependencies from your final runtime image, which drastically reduces image size and improves security.
In practice, you can have one stage with a full SDK to compile your application and a second, minimal stage that only contains the runtime and the built binaries. You copy the artifacts from the build stage into the final stage, leaving behind all the unnecessary tools and intermediate files.
This eliminates the need for complex shell scripting and manual cleanup steps to shrink images. It's a cleaner, more maintainable approach to building lean production images.
Example Dockerfile
FROM golang:1.20 AS builder
WORKDIR /app
COPY . .
RUN go build -o myapp .
FROM alpine:latest
WORKDIR /root/
COPY --from=builder /app/myapp .
CMD ["./myapp"]
What is the experimental BuildKit integration?
Docker 17.05 lays the groundwork for a new build backend called BuildKit, available by setting the environment variable DOCKER_BUILDKIT=1. This experimental feature is designed to be faster, more efficient, and more secure than the traditional builder.
BuildKit introduces advanced features like parallel build step processing and improved caching mechanisms. It's built with a client-server architecture and provides better control over build secrets and artifacts, preventing accidental leakage into the final image.
While experimental in 17.05, this is the foundation for the modern build system that would later become the default. It's worth trying out for complex build pipelines where performance is critical.
What new commands help with system management?
The docker system family of commands gets new utilities for managing disk space and understanding resource usage. The docker system df command provides a detailed breakdown of how much space your images, containers, and volumes are consuming.
For pruning, docker system prune now includes a --volumes flag. This allows you to clean up not just dangling images, containers, and networks, but also unused volumes in a single command, which is a huge time-saver for developers and admins.
These tools make it much easier to keep your Docker host clean and prevent it from running out of disk space, especially in CI/CD environments where builds happen constantly.
How are Swarm mode services improved?
Service management in Swarm mode is enhanced with the ability to perform rolling updates with no downtime. The update mechanism is more robust, allowing for better control over how new service tasks replace old ones.
Logging for services is also improved. You can now use docker service logs to fetch logs from services running in a Swarm, which provides a centralized view of your application output across all the nodes and replicas in the cluster.
Furthermore, docker stack deploy now natively supports Docker Compose files. This simplifies the process of deploying complex application stacks defined in a docker-compose.yml file directly to a Swarm cluster.
FAQ
Why are multi-stage builds such a big deal?
They solve the fundamental problem of creating bloated production images. Before, you had to include all build tools in your final image or use brittle shell scripts to copy artifacts between images. Multi-stage builds make creating small, secure images a native and straightforward Docker feature.
Should I enable the experimental BuildKit backend for my builds?
If you're in a development environment and want to experiment with faster builds and future-facing features, yes. For critical production builds, you might want to stick with the stable builder until BuildKit matures, as its behavior and CLI output were still experimental in this release.
What happens with the deprecated shortened image ID prefixes?
Docker is moving towards using full, 64-character image IDs in its API responses for consistency and to prevent collisions. Scripts that parse the CLI output and rely on the shorter 12-character prefixes will need to be updated to handle the longer format.
Can I now deploy my existing docker-compose.yml files to Swarm?
Yes, the docker stack deploy command now accepts Compose files directly. This greatly simplifies the workflow from local development using docker-compose up to deploying the same application stack to a production Swarm cluster.
How do I clean up unused volumes easily now?
Use the command docker system prune --volumes. Be very careful with this command, as it will delete all volumes not currently used by at least one container, which could result in data loss if you're not sure what you're doing.