V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
yhm2046
V2EX  ›  git

在 docker 执行 git 很慢是什么原因?

  •  
  •   yhm2046 · 2022-11-17 09:37:43 +08:00 · 1799 次点击
    这是一个创建于 498 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在公司服务器中下载 image 镜像到本地,git status, git add, git commit 这些命令都很慢, 都运行几个小时,我查了一下在我一个人用服务器时候也是很慢, 另外在 docker 而是直接在硬盘上的代码运行就是正常的, 这种情况是什么原因导致?

    7 条回复    2022-11-25 20:26:13 +08:00
    imdong
        1
    imdong  
       2022-11-17 09:45:47 +08:00 via iPhone
    已知 docker 在 Mac 下,映射进去的目录,小文件性能很差。
    amrnxcdt
        2
    amrnxcdt  
       2022-11-17 09:46:34 +08:00   ❤️ 1
    docker 运行的容器是 overlayfs 文件系统,写入慢,用--mount 挂载 host 上的的路径进行读写就快一些。
    参考:
    https://docs.docker.com/storage/storagedriver/overlayfs-driver/
    https://docs.docker.com/storage/bind-mounts/
    seers
        3
    seers  
       2022-11-17 09:48:35 +08:00 via Android
    挂个 mem 盘进去看看,是不是磁盘导致的
    yhm2046
        4
    yhm2046  
    OP
       2022-11-23 09:33:04 +08:00
    @amrnxcdt 你好我用了 --mount 命令测试感觉还是没有快多少, 而且设置时间的命令也用不了

    sudo docker run -d --privileged -it \
    --mount type=bind,source=/datastore1/x9,target=/host \
    --name sd_build_x9 sd_build_3 /bin/bash
    amrnxcdt
        5
    amrnxcdt  
       2022-11-24 18:36:41 +08:00
    @yhm2046 #4 你要提供更多信息大家才能帮你判断。比如你的 docker 版本和 host 系统是什么? docker 镜像是什么系统、镜像内和 host 上的 git 版本什么的。
    yhm2046
        6
    yhm2046  
    OP
       2022-11-25 11:41:30 +08:00
    @amrnxcdt 宿主机器:
    Docker version 20.10.17, build 100c701
    Description: Ubuntu 22.04.1 LTS

    docker 镜像
    sudo docker exec -it df01ded745cd /bin/bash
    git version 2.7.4
    Ubuntu 16.04.7 LTS

    另外设置时间问题我已经解决了,参考 https://blog.csdn.net/ju_362204801/article/details/114383191
    不过现在在 docker 里面编译出现报错, 我怀疑是挂载命令出错,因为我用-v 挂载是可以正常编译没有问题的
    //原来的命令
    sudo docker run --privileged -it -d -v /datastore1/x9r:/host --name sd_build sd_build_3 /bin/bash
    //报错 log
    make[2]: Entering directory '/host/x9/ptg4.1/buildsystem/atf/atf/arm-trusted-firmware'
    /bin/sh: 1: /tool/gcc_linaro/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc: not found
    Including services/spd/trusty/trusty.mk
    Building x9
    CC lib/libc/abort.c
    CC lib/libc/assert.c
    make[2]: /tool/gcc_linaro/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc: Command not found
    CC lib/libc/exit.c
    make[2]: /tool/gcc_linaro/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc: Command not found
    Makefile:802: recipe for target '/host/x9/ptg4.1/buildsystem/atf/atf/arm-trusted-firmware/sml/x9/release/libc/abort.o' failed
    make[2]: *** [/host/x9/ptg4.1/buildsystem/atf/atf/arm-trusted-firmware/sml/x9/release/libc/abort.o] Error 127
    CC lib/libc/memchr.c
    make[2]: *** Waiting for unfinished jobs....
    Makefile:802: recipe for target '/host/x9/ptg4.1/buildsystem/atf/atf/arm-trusted-firmware/sml/x9/release/libc/assert.o' failed
    make[2]: *** [/host/x9/ptg4.1/buildsystem/atf/atf/arm-trusted-firmware/sml/x9/release/libc/assert.o] Error 127
    make[2]: /tool/gcc_linaro/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc: Command not found
    Makefile:802: recipe for target '/host/x9/ptg4.1/buildsystem/atf/atf/arm-trusted-firmware/sml/x9/release/libc/exit.o' failed
    make[2]: *** [/host/x9/ptg4.1/buildsystem/atf/atf/arm-trusted-firmware/sml/x9/release/libc/exit.o] Error 127
    make[2]: /tool/gcc_linaro/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc: Command not found
    Makefile:802: recipe for target '/host/x9/ptg4.1/buildsystem/atf/atf/arm-trusted-firmware/sml/x9/release/libc/memchr.o' failed
    make[2]: *** [/host/x9/ptg4.1/buildsystem/atf/atf/arm-trusted-firmware/sml/x9/release/libc/memchr.o] Error 127
    make[2]: Leaving directory '/host/x9/ptg4.1/buildsystem/atf/atf/arm-trusted-firmware'
    sml_setup.mk:53: recipe for target 'atf_build' failed
    make[1]: *** [atf_build] Error 2
    make[1]: Leaving directory '/host/x9/ptg4.1/buildsystem/atf/atf/arm-trusted-firmware'
    Makefile:1429: recipe for target 'build_ap2atf' failed
    make: *** [build_ap2atf] Error 1
    amrnxcdt
        7
    amrnxcdt  
       2022-11-25 20:26:13 +08:00
    @yhm2046 #6 -v 和--mount 就是默认参数的区别,参考: https://docs.docker.com/storage/volumes/#choose-the--v-or---mount-flag

    参考 make 的错误是 Entering directory ,应该是--mount 缺少参数了,如果-v 可以用直接用-v 就行。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2837 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 13:22 · PVG 21:22 · LAX 06:22 · JFK 09:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.