• 请不要在回答技术问题时复制粘贴 AI 生成的内容
chaleaochexist
V2EX  ›  程序员

docker build 失败 如何调试?

  •  
  •   chaleaochexist · May 31, 2023 · 2509 views
    This topic created in 1101 days ago, the information mentioned may be changed or developed.

    之前老版本我记得 docker build 如果失败也会在 docker images 里看到中间结果, 也就是失败之前的那个镜像.我之前的习惯是 run 那个镜像 然后手动执行下一条看为什么报错. 去 debug.

    现在没有了, 失败了 docker images 里是空的.

    请问专业的运维大佬是如何调试 dockerfile 的?

    10 replies    2023-05-31 16:40:30 +08:00
    defunct9
        1
    defunct9  
       May 31, 2023
    开 ssh ,让我上去看看
    SingeeKing
        2
    SingeeKing  
    PRO
       May 31, 2023   ❤️ 1
    除非 multi-stage 不然应该不会存在所谓的「之前的那个镜像」的;这个可以用 BuildKit 然后指定 `--cache-to` 来保存每步缓存
    chaleaochexist
        3
    chaleaochexist  
    OP
       May 31, 2023
    @SingeeKing 难道我记错了..
    C1V7dYXW4PN67euV
        4
    C1V7dYXW4PN67euV  
       May 31, 2023
    进入 images
    docker run -ti --entrypoint /bin/sh xxx
    Latin
        5
    Latin  
       May 31, 2023
    docker 的设置 buildkit 为 true 时会折叠每层的日志输出 并且构件这层报错时也会忽略,失败构建也会保存到镜像库中
    photon006
        6
    photon006  
       May 31, 2023   ❤️ 1
    加 progress 参数:

    docker build --progress=plain --network=host -t hello/world:latest .
    hhjswf
        7
    hhjswf  
       May 31, 2023
    肉眼扫一眼
    tramm
        8
    tramm  
       May 31, 2023
    问如何调试不如直接贴 Dockerfile 来的实在, 哈哈
    taoge0224
        9
    taoge0224  
       May 31, 2023
    call me
    anubu
        10
    anubu  
       May 31, 2023   ❤️ 1
    基础镜像挂源码卷拉一个容器,在容器里手动执行 Dockerfile 中的指令进行调试。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5383 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 07:10 · PVG 15:10 · LAX 00:10 · JFK 03:10
    ♥ Do have faith in what you're doing.