About a year ago I published a blog post called "A Tale of Two Onboardings" that was widely shared. I think people responded to it, because it painted a picture of an easier world where a development machine with Docker installed can boot anything you need for your development workflow with a single command.
This kind of workflow — where you develop inside a running container — has been a promise of Docker for as long as I’ve known about it, but a great developer experience has never been fully realized, until now.
The Convox CLI now has the ability to enhance Docker usage with 2-way code sync. In the latest release, convox start
will instantly sync file changes from your Docker host to your container and from your container to your host. This enables you to:
When you run convox start
, the CLI watches the files on your host and copies any changes to your built container(s).
It also copies a small Linux binary onto your built containers to watch for changes there. This binary logs changes to STDOUT where the CLI is listening, and the CLI copies changed files back to the host.
Files are only synced with containers that are built from a Dockerfile in your project, and only files and directories that appear in COPY or ADD statements in the Dockerfile are synced.
But wait a minute. Isn’t this what Docker volume mounts are for? Well, yes and no. Docker volumes are a good way to share files between the host and container in some cases, but sharing your whole code directory comes with a couple of known, gnarly problems.
With this feature you can finally realize true container-based development with Docker! This has many powerful implications:
You can try this out today by downloading and installing the convox CLI:
$ curl -Ls https://install.convox.com/osx.zip > /tmp/convox.zip
$ unzip /tmp/convox.zip -d /usr/local/bin
$ curl -Ls https://install.convox.com/linux.zip > /tmp/convox.zip
$ unzip /tmp/convox.zip -d /usr/local/bin
You’ll also need Docker installed locally. If you’re on OS X be sure to sign up for the Docker for Mac beta.
Once you have the prerequisites installed you can play around with our Rails example:
$ git clone git@github.com:convox-examples/rails.git
$ cd rails
$ convox start
With the app booted you can run docker ps
to get a list of container IDs and then exec onto a container and run Rails commands:
$ docker exec -it <container ID> bash
$ rails g scaffold ...
$ rake db:migrate
Observe the changed files on your local filesystem. Try changing a file locally and observe the file change on the container.
Please join our Slack, and let us know what you think about this feature. Bug reports, feature requests and patches are welcome on the project repo.