V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
chaleaochexist
V2EX  ›  程序员

docker build 失败 如何调试?

  •  
  •   chaleaochexist · 324 天前 · 1371 次点击
    这是一个创建于 324 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

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

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

    docker build --progress=plain --network=host -t hello/world:latest .
    hhjswf
        7
    hhjswf  
       324 天前
    肉眼扫一眼
    tramm
        8
    tramm  
       324 天前
    问如何调试不如直接贴 Dockerfile 来的实在, 哈哈
    taoge0224
        9
    taoge0224  
       324 天前
    call me
    anubu
        10
    anubu  
       324 天前   ❤️ 1
    基础镜像挂源码卷拉一个容器,在容器里手动执行 Dockerfile 中的指令进行调试。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1245 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 17:47 · PVG 01:47 · LAX 10:47 · JFK 13:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.