BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News New Docker Compose Functionality Banishes Alt-Tabbing and Bind Mounts

New Docker Compose Functionality Banishes Alt-Tabbing and Bind Mounts

Docker has announced the general availability of Docker Compose Watch, a tool to enhance application development efficiency, making it easier for developers to maintain their focus while coding.

Traditionally, containerized application development entails many steps beyond the simplicity of an Alt+Tab and hitting the refresh button in a web browser. Even with caching, the process of rebuilding the image, recreating the container, and dealing with stop-start times can be a distraction from core development work. Docker Compose Watch is intended to address this inconvenience, focusing specifically on the common friction points observed during development.

Docker Compose Watch allows developers to synchronize their code changes into the container running their code, enabling live reload for technologies like React or NextJS. It offers fine-grained control over how local file changes are synced into the container, preventing changes made for testing purposes that are not intended to be kept from being maintained. It introduces "hot reload", enabling seamless and almost instant updates to an application as code is written, all without losing the existing state of the app.

One common traditional workaround for achieving hot reload is to set up a bind mount, which mirrors file changes between the local system and a container. However, this approach often requires some workarounds, as the functioning of bind mounts in Docker Desktop differs from that in Docker Engine on Linux. Ensuring seamless and efficient file sharing between the local machine and the virtual machine (VM) of Docker Desktop while maintaining permissions and file notifications presents a significant challenge.

Docker Compose Watch can automatically build and start all required services at launch, eliminating the need to attach to an already-running Compose project. A single command, "docker compose watch," is all it takes to get started, streamlining the development process and allowing developers to maintain their focus on what matters most: writing code.

Maciej Pankanin commented on X (formerly Twitter) that it would be useful to add restart commands for common services such as nginx; feedback that the development team has noted. Michael Irwin writes positively on X that he "no longer mounts source code" and "things seem much more snappy". And, commenting in a video posted to X, on the earlier alpha release, Bret Fisher says:

"This solves a big performance problem on Mac that we've struggled with for years"

Since its alpha launch in Compose v2.17 bundled with Docker Desktop 4.18, Docker Compose Watch has been improved for GA. Fixes include batching up Docker API calls for speed, using a debounce mechanism to ensure that rebuilds are not done too close together, and adding filters to ignore temporary files generated by common code editors and IDEs.

Docker Compose Watch is now generally available and installable standalone, bundled into Docker Desktop 4.24, and as a plugin for Docker Engine.

About the Author

Rate this Article

Adoption
Style

BT