Docker in MacOs is very slow

前端 未结 5 1582
囚心锁ツ
囚心锁ツ 2020-12-01 16:14

I have this docker-compose.yml:

version: \"3.1\"
services:

    memcached:
      image: memcached:alpine
      container_name: universal-memcached2

    redi         


        
5条回答
  •  爱一瞬间的悲伤
    2020-12-01 16:36

    As mentioned in other answers, the issue comes down to the way Docker interacts with the file system on OSX.

    I found a great article on how to make things a lot faster on OSX:

    https://vivait.co.uk/labs/docker-for-mac-performance-using-nfs

    From the article, the real solution is to change the file system to use NFS, but as I know nothing about Docker (it was set up for me at work), I opted to use an option available in newer versions of Docker

    I added :delegated to all of the options under volumes in docker-compose.yml. After restarting my containers, every was nearly twice as fast as before. Not as fast as native, but fast enough.

    Example from article:

    app:
        build:
            context: .
            dockerfile: ./docker/app/Dockerfile
        working_dir: /app
        user: "www-data"
        volumes:
            - ./:/app:delegated
            - ./:/another_folder:delegated
    

    The NFS example is quite long and requires basically copying half of the article so I won't add it in, but this :delegated solution is good place to start.

提交回复
热议问题