A couple of years ago, Will Pleasant-Ryan wrote Docker for Mac: Overcoming Slow Mounted Volumes, describing his desire to use Docker for local development. He talked about some of the filesystem performance problems that can arise when using a shared volume from the host machine on Mac OS X, along with some potential workarounds and word of some upcoming performance improvements.
- Mount Ext4 Mac
- Docker For Mac Slow Ext4 Partition Recovery
- Docker For Mac Slow Ext4 Partition Restore
- Mac Slow Internet Connection
- Linux Shrink Ext4 Partition
- Because of that, Docker runs on Mac OS slowly. You are not able to run the Docker on Mac OS like on Linux. If I need to give some instances about real use-cases. I have the same machine. So, I use Symfony 4 on Docker v18 on Mac OS Mojave. This is my Symfony total execution time on Docker.
- Docker For Mac Slow Ext4 Partition Steam For Mac Review Gintama Season 2 Sub Indo Download Allahuma Shali Wash Watch Resident Evil 4 Online Pdf2jpg Reviews Of Bio Snazio Dtvpvr S Usb2 Driver For Mac Usb Vid 090c Pid 1000 Rev 1000 Review Windows Installer Kb893803 V2 X64 Or X86.
Mount Ext4 Mac
Use docker save to save containers, and push existing images to Docker Hub or a private repository, so that you not need to re-create them later. Btrfs requires a dedicated block storage device such as a physical disk. This block device must be formatted for Btrfs and mounted into /var/lib/docker/. The configuration instructions below walk you.
In the time since that post was written, those improvements have been released. But I’ve still found it to be unacceptably slow to have the source code mounted from the host machine, at least for something like a Ruby on Rails application.
However, earlier this summer, a Visual Studio Code update introduced the ability to “attach to a running container.” Once attached, the experience when editing files that reside on a container using VS Code is nearly indistinguishable from that of editing files on the local filesystem with VS Code!
Docker For Mac Slow Ext4 Partition Recovery
1. Docker Compose
I’m using Docker Compose to manage the containers that make up my development environment. There’s plenty of existing documentation on how to use Docker Compose, but I want to point out a couple of things that I’ve done because I’m using a container to host the source code I’m editing.
A named volume for source code
If you just checked out a repository into a normal directory inside the container, you’d have to be careful not to lose any changes that had not been committed and pushed whenever making changes to container (updating something in the Dockerfile
, etc.). But if the source code is checked out into a named volume, the container can be re-built over and over again, with your source code being mounted exactly as it was before.
A long-running container
Similar to a database container, your “dev” container should stay running when you do a docker-compose up
so you can attach to it from VS Code. With Docker Compose, you just need to set the tty
option to true
in your docker-compose.yml
.
Here’s an example docker-compose.yml
file that has a couple of named volumes, one for the source code directory and the other for the contents of the database. I’m using this for an old Ruby on Rails project, hence the old version of MySQL.
2. Working in the Dev Container
Docker For Mac Slow Ext4 Partition Restore
The idea is that any developer could check out the repository on their laptop, run docker-compose up
, and have a working development environment. But you’ll still need a little customization of the container once it’s been built.
Check out the source code
Once you have your container up and running (docker-compose up
), you’ll need to check out your source code inside the container. You can’t do this as part of the Dockerfile
because we want the repository to live in the mounted volume.
If you rely on your SSH keys to authenticate with your Git server, then you’ll want to either mount your ~/.ssh
directory in the container or copy your private key into the container manually. I needed to do the latter because my ~/.ssh/config
has some things that aren’t compatible with the Ubuntu version running in the container.
These examples assume the container will be run as a user called “dev.”
I also like to have my normal Git configuration available as well:
Now you just check out your source code, but inside the container instead of on your host machine.
At this point, you can open a shell in the container and run tests, start the development server, etc.
3. Editing in VS Code
With the “dev” container running, inside of Visual Studio Code, run the “Remote-Containers: Attach to Running Container” command and select your “dev” container. VS Code will attach and install everything it needs to run on the container.
If you select the File Explorer, you’ll see an “Open Folder” button that, when clicked, will display folders on the container. Select the location of the source code that was checked out previously, and click OK. You’ll now be able to edit files as if they were hosted on the local filesystem.
You can even open an integrated terminal in VS Code, and it will automatically open a shell in the attached container!
Mac Slow Internet Connection
Conclusion
I’ve only recently started playing with hosting my entire development environment, including the source code, inside Docker containers, but the experience using VS Code as an editor has been fantastic.
Linux Shrink Ext4 Partition
With the Mac OS X filesystem integration performance improvements that have been made, many projects will be just fine using shared volumes mounted from the host system. But in cases where that just won’t cut it, hosting the source in the container and using VS Code to attach to the container is a really, really nice solution.