英文:
Is it possible to use mounts and heredocs in the same RUN command in a dockerfile
问题
I'm using docker 24.0.1 on an Ubuntu 22.04 install
给定以下Dockerfile:
FROM ubuntu:22.04
RUN --mount=type=cache,target=/var/apt/cache << EOT
apt-get update -qq
apt-get install -y apt-utils
EOT
当我运行此文件的构建时,我得到:
dockerfile:6
--------------------
4 |
5 | RUN --mount=type=cache,target=/var/apt/cache << EOT
6 | >>> apt-get update -qq
7 | apt-get install -y apt-utils
8 | EOT
--------------------
ERROR: failed to solve: dockerfile parse error on line 6: unknown instruction: apt-get
我不确定为什么这两个特性会与彼此不兼容,但考虑到它们是较新的特性,也许它们是不兼容的。有人成功地同时使用它们吗?我是否漏掉了一些东西?
英文:
I'm using docker 24.0.1 on an Ubuntu 22.04 install
Given the following dockerfile:
FROM ubuntu:22.04
RUN --mount=type=cache,target=/var/apt/cache << EOT
apt-get update -qq
apt-get install -y apt-utils
EOT
When I run the build for this file, I get:
dockerfile:6
--------------------
4 |
5 | RUN --mount=type=cache,target=/var/apt/cache << EOT
6 | >>> apt-get update -qq
7 | apt-get install -y apt-utils
8 | EOT
--------------------
ERROR: failed to solve: dockerfile parse error on line 6: unknown instruction: apt-get
I'm not sure why the two features would be incompatible with one another, but given they're newer features, maybe they are. Has anyone had success using both together? Is there something I'm missing to do so?
答案1
得分: 1
David发现了我的错误 - 那个多余的空格是我犯的错。去掉那个空格就修复了构建。
英文:
David caught my error - the typo of the extra space was what caught me off. removing that space fixed the build.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论