当Docker组合Onts输出目录作为音量时

发布于 2025-02-04 11:50:12 字数 2696 浏览 3 评论 0原文

我正在使用Docker-Compose来构建BuildRoot存储库,并希望将BuildRoot输出目录作为音量安装,因为它对于获取生成的图像而无需加速Docker容器非常有用。

这是我的docker-compose.yml:

version: '3' 

services:
  db: 
    image: mycustom
    container_name: mucustom-container
    command: /bin/bash -c "clone-repo.sh && bash"
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
        ./output:/usr/local/share/broot/my-custom/output

脚本clone-repo.sh仅用于克隆buildroot存储库(包括用于参考):

#!/bin/bash
REPO=my-custom
BUILDROOT=/usr/local/share/broot/
# Create BUILDROOT
mkdir -p $BUILDROOT/$REPO
cd $BUILDROOT/$REPO
# Clone repo
if [ ! -d $BUILDROOT/$REPO/.git ]; then
    git init
    git remote add origin [email protected]:my/platform/$REPO.git
    git pull origin master
    git fetch
fi

使用此版本的docker-compose,

$ docker-compose --version
docker-compose version 1.29.1, build c34c88b2

docker映像按预期构建,构建过程和构建过程BuildRoot工作正常。

但是,我已将Docker迁移到此版本:

$ docker --version
Docker version 20.10.5, build 55c4c88

注意此特定版本的“ compose”是Docker工具中包含的功能。使用此Docker版本,docker映像是按预期构建的。但是,Buildroot的构建过程失败:

*** Error during update of the configuration.
Makefile:999: recipe for target 'syncconfig' failed
make[1]: *** [syncconfig] Error 1

分析BuildRoot源代码后,该问题是由 在此源文件中定义的“重命名”函数:support/kconfig/concdata.c

name = getenv("KCONFIG_AUTOHEADER");
if (!name)
    name = "include/generated/autoconf.h";
sprintf(buf, "%s.tmpconfig.h", dir);
if (rename(buf, name))
    return 1;
name = getenv("KCONFIG_TRISTATE");
if (!name)
    name = "include/config/tristate.conf";
sprintf(buf, "%s.tmpconfig_tristate", dir);
if (rename(buf, name))
    return 1;
name = conf_get_autoconfig_name();
sprintf(buf, "%s.tmpconfig", dir);
if (rename(buf, name))
    return 1;

所有以1重命名返回的调用。深入分析问题,发现该时间文件的生成良好:

a) /usr/local/share/broot/my-custom/.tmpconfig.h
b) /usr/local/share/broot/my-custom/.tmpconfig_tristate
c) /usr/local/share/broot/my-custom/.tmpconfig

但是它们无法重命名为位于目标路径的目标路径,在输出目录(记住是作为音量安装的):

a) /usr/local/share/broot/my-custom/output/build/buildroot-config/autoconf.h
b) /usr/local/share/broot/my-custom/output/build/buildroot-config/tristate.config
c) /usr/local/share/broot/my-custom/output/build/buildroot-config/auto.conf

Docker-Compose工具(带有Hyppen)和Docker组成(没有Hyppen)之间的实现有何不同?您知道为什么Docker-Compose允许这样做吗?为什么Docker组成不支持这一点?

I'm using docker-compose to build a buildroot repository, and want to mount the buildroot output directory as a volume, as it is quite useful for getting generated images without accesing the docker container.

This is my docker-compose.yml:

version: '3' 

services:
  db: 
    image: mycustom
    container_name: mucustom-container
    command: /bin/bash -c "clone-repo.sh && bash"
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
        ./output:/usr/local/share/broot/my-custom/output

The script clone-repo.sh is just used to clone the buildroot repository (included for reference):

#!/bin/bash
REPO=my-custom
BUILDROOT=/usr/local/share/broot/
# Create BUILDROOT
mkdir -p $BUILDROOT/$REPO
cd $BUILDROOT/$REPO
# Clone repo
if [ ! -d $BUILDROOT/$REPO/.git ]; then
    git init
    git remote add origin [email protected]:my/platform/$REPO.git
    git pull origin master
    git fetch
fi

Using this version of docker-compose,

$ docker-compose --version
docker-compose version 1.29.1, build c34c88b2

the docker image builds as expected, and the build process of buildroot works fine.

However, I have migrated docker to this version:

$ docker --version
Docker version 20.10.5, build 55c4c88

Note for this particular version, "compose" is a functionality included inside the docker tool. Using this docker version, docker image is built as expected. However, the build process of buildroot fails:

*** Error during update of the configuration.
Makefile:999: recipe for target 'syncconfig' failed
make[1]: *** [syncconfig] Error 1

After analyzing buildroot source code, the problem is generated with the
"rename" functions defined in this source file: support/kconfig/confdata.c

name = getenv("KCONFIG_AUTOHEADER");
if (!name)
    name = "include/generated/autoconf.h";
sprintf(buf, "%s.tmpconfig.h", dir);
if (rename(buf, name))
    return 1;
name = getenv("KCONFIG_TRISTATE");
if (!name)
    name = "include/config/tristate.conf";
sprintf(buf, "%s.tmpconfig_tristate", dir);
if (rename(buf, name))
    return 1;
name = conf_get_autoconfig_name();
sprintf(buf, "%s.tmpconfig", dir);
if (rename(buf, name))
    return 1;

All calls to rename return with 1. Analyzing the issue deeply, found this temporal files are generated fine:

a) /usr/local/share/broot/my-custom/.tmpconfig.h
b) /usr/local/share/broot/my-custom/.tmpconfig_tristate
c) /usr/local/share/broot/my-custom/.tmpconfig

But they can't be renamed to destination paths, located at output directory (remember, mounted as a volume):

a) /usr/local/share/broot/my-custom/output/build/buildroot-config/autoconf.h
b) /usr/local/share/broot/my-custom/output/build/buildroot-config/tristate.config
c) /usr/local/share/broot/my-custom/output/build/buildroot-config/auto.conf

What's different in the implementation between docker-compose tool (with hyppen) and docker compose (without hyppen)? Do you know why docker-compose allows this? And why docker compose is not supporting this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↙厌世 2025-02-11 11:50:12

较新的Docker版本使用其他类型的文件系统组合来安装卷。结果,/usr/local/share/broot/my-custom/usr/usr/local/share/share/broot/my-custom/output现在是不同的文件系统,而且不可能跨文件系统 rename()。

作为解决方法,要么安装/usr/locar/local/share/broot/my-custom作为卷,或者使用使O = ...使用外部 - 树的构建。在后一种情况下,临时文件将在指定的输出目录中而不是在buildroot目录中创建。请注意,要为此起作用,必须将其安装在/usr/usr/local/share/broot/my-custom/output上以外的其他地方。

The newer docker version uses a different type filesystem combining to mount the volume. As a result, /usr/local/share/broot/my-custom and /usr/local/share/broot/my-custom/output are now different filesystems, and it is not possible to rename() across filesystems.

As a workaround, either mount /usr/local/share/broot/my-custom as a volume, or use make O=... to use an out-of-tree build. In the latter case, the temporary files will be created in the specified output directory instead of in the buildroot directory. Note that for this to work, it must be mounted somewhere else than on /usr/local/share/broot/my-custom/output.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文