Docker/phoenix development environment (MacOS)

Hi! Does anybody have a docker development environment for MacOS they’re really happy with? If so, how did you get reasonable performance while syncing source code from host to container? We’ve tried using bind mounts in the past and are now on docker-sync. While docker-sync is reasonably performant, it very occasionally silently fails to sync changes (and of course, anything less than 100% reliability in this domain is problematic).

1 Like

I use Mac OS with Docker and Kubernetes. No performance issues, but I don’t use or knew about docker-sync.
We build multi-stage builds with distillery similar to this Guide .
It is really easy and fast to deploy a new build.

Can you elaborate on what exactly you mean by the performance of source code syncing isn’t great from host to container?

I assume you mean something like the following but please let me know if this is correct:

  • You are mounting a volume (something like docker run -v /foo/bar:/app ...
  • Then you are editing code outside the container from the host
  • You are then running something like mix phx.server which does code reloading but it is not performant

I personally have started to do development with Docker and Elixir recently but I am developing with Vim inside the container so I don’t have much experience with the performance of volumes. I’m also just compiling and running code so I’m not using things like mix phx.server which watch the filesystem, but I’m interested to know more about what you mean and what the problem is.

@pedromvieira Are you saying that doing something like mix phx.server that watches the filesystem inside your container is performant for you when you edit code outside the container?

Yes, the basic idea is to edit source code on the host and have it sync to the container. On the container, we are running tests and the server in development mode. Originally we were using a mounted volume but we had to move away from that approach. Running tests and the server was too slow, and when we created, renamed, or deleted files the sync process would crash. Now we use docker-sync, which is a great improvement in terms of performance and reliability, but every so often (once every couple days or so), it will silently fail to sync a change to the source code.

Editing the source code with a terminal-based editor on the container (like you do) probably would do the trick, but not all our devs use terminal editors.

In my case, if I need to run multiple nodes in docker I start each container by mapping source folder on host as containers mount.

Check this so answer for more details https://stackoverflow.com/a/47272481

Also, i’m not deleting container as long as i need to work on that project.

Btw i’m using alpine elixir docker image, so it is small and boots quickly, so I dont see any difference in node startup time comparing to case when I run node on bare metal

Btw, i have to mention that docker-sync could be bottle neck if your docker vm is not using raw vm image. So check config of your docker and convert vm image to raw if you need.

Check this article for more details https://medium.com/@TomKeur/how-get-better-disk-performance-in-docker-for-mac-2ba1244b5b70

Thanks for the suggestion. Yes, we’re already using the raw filesystem.

We don’t develop inside container, only at Mac OS. We test our builds with distillery / Docker before production.

1 Like