Code Sync

Convox enhances your development experience by automatically syncing code changes between your host and containers.

Syncing files from the host to the container enables you to develop live in your container. Edit files on your computer using your favorite editor, and Convox will sync changes into the container instantly so that you can see the effects of the changes.

Files edited or created in the container will also get synced back into the host. This comes in handy for frameworks like Rails, for example, where lots of code is generated by the framework. You can run a generator inside the container and then see the files on your host where they can be edited, committed to version control, etc.

How does it work?

By default, convox start will synchronize all files or directories that appear in a COPY or ADD directive in your Dockerfile, ignoring any of those files or directories that appear in .dockerignore. It watches these locations on your host and uses the Docker API to copy changed files to the relevant container.

The convox start command also places a small Linux binary onto relevant containers to watch for file changes in the container. The binary logs changes to STDOUT, where convox start is listening. Changed files are then copied from the container to the host using the Docker API.

Why not volumes?

Volumes are useful in many scenarios, but are not ideal for code syncing.

Docker volumes use overlay mounts. That means the host directory is mounted over the corresponding container directory, making any files that previously existed exclusively on the container unavailable. This is problematic if you want to build useful files into a base Docker image that your app’s Dockerfile inherits from.

There are also known performance problems using Docker volumes to sync large numbers of small files in non-Linux environments.

Disabling code sync

If you don’t want to use code sync you can disable it by passing the --no-sync option to convox start.