You can also take a look at docker-sync and docker-bg-sync projects to try different approaches and see what works better for you. This option is macOS specific and is used by default with both VirtualBox and Docker Desktop. So as a conclusion it’s worth trying to set up NFS volume for your local dev env. cmd4: NODE_ENV=production npm run buildĪs you can see on a chart below NFS configuration clearly wins (not significantly, but noticable when frequently execute them during the day).cmd1: poetry run python manage.py collectstatic.Those do a lot of file-related operations, so will be indicative for our tests. I have selected couple of popular commands used when developing simple Django/React based web application. That’s it, let’s check what has been changed about performance. Kubernetes containers are mostly used for stateless applications, where each instance is disposable, does not store data that needs to be persisted across restarts inside the container or needed for client sessions as its storage is ephemeral. $ docker-compose -f docker-compose-nfs.yml up -d Prerequisites: A working Kubernetes Cluster A Linux computer or server to run a NFS server Persistent Volumes in Kubernetes. O: addr=,rw,nolock,hard,nointr,nfsvers=3Īnd start your project as usually explicitly providing compose configuration via -f flag 1 If you are doing this just for yourself it’s probably a good idea to even add this file to. $ cp docker-compose.yml docker-compose-nfs.ymlĪ copy of configuration is created not to conflict with your teammates who have different operating systems and this configration will be invalid for them. We are ready to adjust docker-compose.yml file and mount volume the new way 1 Now restart the daemon to pick up added changes 1 Next edit this file sudo vim /etc/nfs.conf to allow Docker’s NFS connections by the daemon 1 It allows sharing any directory within folder specified (so you might specify just a single project’s dir here). Where /Users/username/workspace is a path to the directory where all of your projects reside. Users/username/workspace -alldirs -mapall=501:20 localhost
Using NFS volume insteadįirst of all create this file (or edit it if exists) sudo vim /etc/exports 1 It gives some of improvement, but couple of commands might gain you another extra seconds while developing, so meet NFS. is a current working directory for the project) 1 Unfortunately, performance for the file-related operations on MacOS is really horrible and it’s kinda a well-known issue.Ĭommon solution usually is to set cached option on a volume like this (.
#Docker for mac nfs volume code#
We are using docker/ docker-compose as a development environment for our project and to sync the code between container and IDE volume is used.