

One such task is the installation of Rails. In order to evaluate the performance of different sync strategies, we need to execute a repeatable task that results in heavy IO load. The issue is compounded when you have applications that make changes to large amounts of small files, as each change made on the host needs to be detected and propagated to the container, and vice-versa.

While Docker has made great strides in improving sync performance, the process is still much slower than running natively without syncing. Along with the VM comes a filesystem sharing utility called “osxfs” which is in charge of keeping the filesystem native to your Mac in sync with the linux-based filesystem of your docker containers. Therefore, in order for Docker Desktop for Mac to function, it runs a linux virtual machine. On your Mac, these resources do not exist. Problem solved, right?ĭocker works its magic by leveraging features of the linux kernel, notably namespaces (for isolation) and control groups (or cgroups-for resource management). This way when we make a change to a source file on the host, that change is propagated to the container without rebuilding our image, thus keeping the “hot reload” intact. This means that we specify a folder on the host machine (commonly the application working directory) and instruct Docker to keep that directory in sync with a directory in the container. In order to work around this, developers will often create a bind mount.

This is a slow process that hinders our productivity. We would have to rebuild the image to see each change reflected. By default with Docker, this is not possible.
#Docker for mac not starting where are log files code
What about when working with an interpreted language like Javascript, Python, or Ruby? With Ruby on Rails, for example, we are used to the concept of a “hot reload” in which we simply make a change to the source code and see that change reflected upon page refresh. This may mean a simple recompile of the application binary and we are off to the races. Often this is satisfactory, especially when working with compiled languages, as Docker will cache unchanged parts of an image and rebuild only those that have changed. So what happens when you make a change to your code? In order to see that change, you need to rebuild your image and start a new container. When developing in Docker, there are a couple of steps that need to take place in order to get an application running: While there are many more reasons to use Docker, especially in production, these are a few of the benefits you can gain from using it for development, even if its use stops there! So What’s the Problem? If you are deploying an image to production, you are also getting a development environment that more closely resembles that of production-reducing the issue of “it works on my machine!”. This includes the OS, database, language version, and libraries.

Due to the nature of containers, Docker solves this problem for free.
