Docker Compose v2构建镜像失败,但docker build与旧版docker-compose v1.29.2构建成功的问题求助
Docker Compose v2构建镜像失败,但docker build与旧版docker-compose v1.29.2构建成功的问题求助
各位大佬好,我最近碰到一个头疼的问题:同样的Dockerfile,用docker build或者docker-compose v1.29.2执行构建完全正常,但换成Docker Compose v2.16.0时,在Maven打包步骤就会报错,错误信息是:
library initialization failed - unable to allocate file descriptor table - out of memory
看起来应该是资源限制触发了这个问题,但我不清楚怎么在Docker Compose v2里配置构建阶段的ulimits或者资源限制,有没有人知道怎么解决?
我的Dockerfile内容
FROM alpine/git as clone WORKDIR /keycloak RUN git clone https://github.com/maturbet-volta/nexus3-keycloak-plugin.git WORKDIR /cargo RUN git clone https://github.com/sonatype-nexus-community/nexus-repository-cargo.git FROM maven:3.5-jdk-8-alpine as build WORKDIR /keycloak COPY --from=clone /keycloak/nexus3-keycloak-plugin /keycloak RUN mvn -PbuildKar package -Dmaven.test.skip=true WORKDIR /cargo COPY --from=clone /cargo/nexus-repository-cargo /cargo RUN mvn -PbuildKar package FROM sonatype/nexus3:latest COPY --from=build /keycloak/target/*.kar /cargo/target/*.kar /opt/sonatype/nexus/deploy/
环境信息
- Docker Compose版本:
$ docker compose version Docker Compose version v2.16.0
- Docker info输出:
$ docker info Client: Context: default Debug Mode: false Plugins: compose: Docker Compose (Docker Inc., v2.16.0) Server: Containers: 8 Running: 3 Paused: 0 Stopped: 5 Images: 251 Server Version: 20.10.23 Storage Driver: btrfs Build Version: Btrfs v6.1.3 Library Version: 102 Logging Driver: journald Cgroup Driver: systemd Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc Default Runtime: runc Init Binary: /usr/libexec/docker/docker-init containerd version: runc version: init version: Security Options: seccomp Profile: default selinux cgroupns Kernel Version: 6.1.18-200.fc37.x86_64 Operating System: Fedora Linux 37 (Workstation Edition) OSType: linux Architecture: x86_64 CPUs: 8 Total Memory: 31.06GiB Name: fedora ID: JJM4:AEWX:KYZS:3X54:B3GH:3ACD:JK7S:AK4R:CDT2:MT4C:BVHT:CNYK Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Registry Mirrors: https://registry.e.securiton.int/ Live Restore Enabled: true
我尝试过的方向
目前猜测是Docker Compose v2对构建容器的默认资源限制比v1严格,尤其是文件描述符或者内存的限制,但不知道具体怎么在v2里配置这些参数。
希望有大佬能指点一下怎么在Docker Compose v2中调整构建阶段的ulimits或者资源分配,谢谢!
备注:内容来源于stack exchange,提问作者Julien
相关产品推荐
相关产品推荐

