[HN Gopher] Docker on MacOS is slow and how to fix it
       ___________________________________________________________________
        
       Docker on MacOS is slow and how to fix it
        
       Author : riccardomc
       Score  : 46 points
       Date   : 2022-12-22 20:42 UTC (2 hours ago)
        
 (HTM) web link (www.paolomainardi.com)
 (TXT) w3m dump (www.paolomainardi.com)
        
       | EdwardDiego wrote:
       | My preferred fix: don't develop in Docker.
        
         | sieabahlpark wrote:
         | Have fun managing osx and Linux dependencies then when you
         | could just maintain one.
        
           | notwokeno wrote:
           | When I used to use a mac I just put all my "Linux" (GNU
           | really) dependencies in a prefix and that worked pretty well.
           | Docker is kind of overkill for what people use it for IMO.
        
             | dhritzkiv wrote:
             | I used to be on the side of relying on native tools/libs,
             | and managing them in a similar way to what you to describe,
             | but it all became too much to handle, with dependencies
             | across projects breaking with regularity.
             | 
             | Maybe I wasn't doing it right, but switching to Docker to
             | sequester my projects and their dependencies has saved me
             | so much time and hassle, especially with the amount of
             | repos I work on throughout the year.
             | 
             | My biggest weakness today is that I still don't reach for
             | Docker right away when starting work on a new project or
             | when evaluating a new tool. Old habits...
        
             | [deleted]
        
         | thunky wrote:
         | My preferred fix: don't develop in Mac.
        
       | hakanderyal wrote:
       | I finally gave up the effects of Docker on performance and
       | battery life and switched to Windows. I still don't have a long
       | lasting battery, but at least performance is better.
        
         | rad_gruchalski wrote:
         | I have been working in a Citrix workspace Windows machine for
         | the past 6 months with a Ubuntu 20 wsl2. I was very much
         | anxious of the experience before onboarding but I have to say,
         | I barely deal with the Windows side of things. Having said
         | that, if I was to move away from mac, I'd just go directly to
         | Linux.
        
       | therealmarv wrote:
       | Is not this the main way to speed up Docker on Mac: use a beefed
       | up Linux Virtual Machine (VirtualBox, UTM, tart) and run Docker
       | inside this Virtual Machine?
        
         | dijit wrote:
         | the 'DOCKER_HOST' variable (and the fact that all SDK's seem to
         | support it) is honestly the greatest bloody thing in the entire
         | ecosystem.
         | 
         | My workflow for the past 3 years with Docker has been: set up
         | some desktop machine somewhere, configure docker, configure ssh
         | like normal: set DOCKER_HOST=ssh://<tailscale_ip> on my laptop.
         | 
         | Docker responds as if it's local, but I get _absurd_ build
         | /fetch speedup (since the wired connection is faster than Wifi)
         | and it's not running inside a slow VM.
         | 
         | Recently I've been using colima on my Mac natively, but I keep
         | reaching for the DOCKER_HOST option.
        
         | acchow wrote:
         | This assumes you want a distinct storage drive within your VM.
         | 
         | Many developers prefer to code in their host OS but run the
         | image via Docker for Mac. They also want instant real-time code
         | changes to appear inside the running Docker image. I suppose
         | you could have some of the disk live within the VM and the code
         | portions be memory mapped or Rsynced. I haven't thought through
         | the downsides.
        
       | rootusrootus wrote:
       | Funny thing is that I switched from virtualbox for Vagrant on OSX
       | over to Docker because vbox file operations were so incredibly
       | slow.
        
       | doctoboggan wrote:
       | What sort of workloads are people doing where the filesystem
       | access is limiting them? I develop python web apps on a mac and
       | use dockerized postgres and a dockerized flask app. I don't seem
       | to experience any noticeable issues. When I am developing I mount
       | the source code directory as a volume so code edits are synced
       | live into the running docker container.
       | 
       | I also develop frontends using vue, managed by npm. In my
       | experience this doesnt need to be dockerized since npm installs
       | everything in a subdirectory per project. Is there a benefit to
       | running this as a dockerized app?
        
         | taf2 wrote:
         | nginx is pretty unusable via docker - I guess file system cache
         | is the issue...
        
           | osrec wrote:
           | You can turn caching off, I believe.
        
         | jeffrom wrote:
         | Workloads with a lot of files, for example a large elixir web
         | app with hot reload / fswatch enabled, have upwards of 20
         | second page load time. More than enough to mess up my flow.
        
         | pmontra wrote:
         | A customer's Mac with a M1 is only 50% faster than my Intel
         | laptop from 2014 at running Rails tests, because they run in a
         | docker container: 50s vs 75s. The difference between the two
         | machines should be much more than that (CPU, RAM, data bus,
         | etc.)
        
         | xtracto wrote:
         | Magento in docker on Mac is horrible for this reason.
        
         | a_t48 wrote:
         | I work on a _large_ C++ codebase on Linux. If I'm on my main
         | (Linux) machine, things are fine, bind mounts are okay. If I'm
         | stuck on my MacBook then compilation performance is...bad. I
         | suspect it's due to heavy filesystem access from the compiler
         | (reading source, writing object files, etc). At some point I
         | need to confirm this by copying in my source directory.
        
         | zeta0134 wrote:
         | One issue I ran into at my previous employer was pylint on a
         | large Python codebase. Pylint is slow on the best of days, but
         | the difference on an M1 Mac running under docker (to
         | standardize the version and settings across the team) was
         | something like 10x as slow; several *minutes* to lint the
         | codebase, which we absolutely required before code could be
         | checked in. It finally got a lot better when VirtioFS came out,
         | which, when enabled on an arm64 image, sped up filesystem
         | access dramatically; suddenly my lints were taking seconds
         | again.
        
         | _-____-_ wrote:
         | [dead]
        
         | [deleted]
        
       ___________________________________________________________________
       (page generated 2022-12-22 23:00 UTC)