摘自我的Dockerfile:
FROM node:12.18.0
RUN echo "hello world"
RUN psql --version
Run Code Online (Sandbox Code Playgroud)
当我运行时,docker build .即使它们没有被缓存,我也看不到这两个命令的任何输出。文档说docker build默认情况下是冗长的。为什么我看不到命令的输出?我以前见过他们。
它Dockerfile是从基于 Debian 9 的 node:12.18.0 创建的。
Docker 版本 19.03.13,构建 4484c46d9d。
我收到错误:
无法使用前端 dockerfile.v0 解决:无法创建 LLB 定义:清单中的平台不匹配
构建以下 Dockerfile 时:
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8
COPY . /inetpub/wwwroot
Run Code Online (Sandbox Code Playgroud) 鉴于这种Dockerfile:
FROM docker.io/alpine
RUN mkdir test
# RUN umask 0022
COPY README /test/README
COPY --chmod=777 README /test/README-777
COPY --chmod=755 README /test/README-755
COPY FORALL /test/FORALL
COPY --chmod=777 FORALL /test/FORALL-777
COPY --chmod=755 FORALL /test/FORALL-755
RUN ls -la /test
Run Code Online (Sandbox Code Playgroud)
我希望readDocker在构建过程中相应地设置 , write,权限 ( )。executedocker build ./
但最后一个命令返回
total 8
drwxr-xr-x 1 root root 4096 Jun 9 19:20 .
drwxr-xr-x 1 root root 4096 Jun 9 19:20 ..
-rwxrwxrwx 1 root root 0 Jun 9 19:19 FORALL …Run Code Online (Sandbox Code Playgroud) 我在CentOS docker主机上有一个CentOS docker容器.当我使用此命令运行docker镜像时docker run -d --net=host -p 8777:8777 ceilometer:1.x,docker容器获取主机的IP,但没有为其分配端口.
如果我在没有"--net = host"的情况下运行相同的命令,则docker会docker run -d -p 8777:8777 ceilometer:1.x公开端口但使用不同的IP.docker版本是1.10.1.我希望docker容器与暴露端口的主机具有相同的IP.我也在Dockerfile指令中提到EXPOSE 8777但在docker run命令中提到"--net = host"时没有用.
我必须在我的Dockerfile中克隆几个大的回购.克隆单个仓库真的需要一个小时,我希望看到标准的Git进度输出以了解正在发生的事情.
但是,当从Dockerfile启动Git时,我看不到任何git clone输出.打印到控制台的唯一事情是:
Cloning into '/root/lib/opencv'...
POST git-upload-pack (gzip 2052 to 1062 bytes)
Run Code Online (Sandbox Code Playgroud)
然后只是一个沉默.通常,我希望这样的事情:
Cloning into 'opencv'...
POST git-upload-pack (gzip 2040 to 1052 bytes)
remote: Counting objects: 158365, done.
Receiving objects: 8% (12670/158365), 2.32 MiB | 255.00 KiB/s
... and so on ...
Run Code Online (Sandbox Code Playgroud)
如何在docker build中启用git verbose输出?也许我必须开始一些互动模式?
我为mac安装了Docker桌面.版本是1.12.0-rc4-beta19
我用的时候 docker build -t self/centos:java8 .
图像没有名称或标签
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 1581ffcbfd7f 5 minutes ago 196.8 MB
Run Code Online (Sandbox Code Playgroud)
build命令有什么问题?
我docker build在构建内存和 CPU 的限制下运行。为了保持在构建的 CPU 和内存限制内,我还将 Node 的堆大小限制为 325 MB。这是docker build命令。
docker build --build-arg NODE_OPTIONS=--max-old-space-size=325 \
--memory=600m --memory-swap=-1 \
--cpu-period=100000 --cpu-quota=50000 \
--no-cache --tag farm_app_image:latest --file Dockerfile .
Run Code Online (Sandbox Code Playgroud)
尽管节点堆限制低于构建内存,并且尽管具有无限交换,但npm run build该react-scripts build步骤的内存不足。
> react-scripts build
Creating an optimized production build...
EXEC : FATAL error : Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory …Run Code Online (Sandbox Code Playgroud) 以下命令不显示输出ubuntu1图像:
docker buildx build -f 1.dockerfile -t ubuntu1 .
docker image ls | grep ubuntu1
# no output
Run Code Online (Sandbox Code Playgroud)
1.docker文件:
FROM ubuntu:latest
RUN echo "my ubuntu"
Run Code Online (Sandbox Code Playgroud)
另外,我无法在其他 docker 文件的语句中使用该图像FROM(两个版本都在我的本地 Windows 机器上):
2.docker文件:
FROM ubuntu1
RUN echo "my ubuntu 2"
Run Code Online (Sandbox Code Playgroud)
docker buildx build -f 2.dockerfile -t ubuntu2 .
#error:
WARNING: No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into …Run Code Online (Sandbox Code Playgroud) 我有一个相当大的具有多层的 Dockerfile。其中一些层需要相当长的时间。我注意到很多事情并不相互依赖。
因此,显而易见的问题是:我可以docker build并行吗?
docker构建似乎只有限制构建速度的选项,而不是加速它(例如--memory)。
示例:假设您有一个Dockerfile看起来像这样的。我现在想调用一个docker build --some-flag并行构建所有阶段的函数,除非它们必须相互协作。
FROM someImage AS stage1
# do some task
FROM otherImage AS stage2
# do another taks
FROM yetAnotherImg As stage3
# more work
COPY --from=stage2 ... # stage3 has to wait for stage2 to finish
Run Code Online (Sandbox Code Playgroud)
你知道是否--some-flag存在吗?您知道如何实现目标的不同方式吗?
编辑:
我唯一能想到的就是将 Dockerfile 分成更多阶段,从而使修改不那么痛苦,但这并不是一个真正理想的解决方案
新来的,想知道是否有人有以非 root 用户身份构建映像的经验?
我正在构建 Kotlin 项目(两步构建),我现在的目标是以非 root 用户身份构建它。这是我的 Dockerfile 的样子。任何帮助,将不胜感激:
# Build
FROM openjdk:11-jdk-slim as builder
# Compile application
WORKDIR /root
COPY . .
RUN ./gradlew build
FROM openjdk:11-jre-slim
# Add application
COPY --from=builder /root/build/libs/*.jar ./app.jar
# Set the build version
ARG build_version
ENV BUILD_VERSION=$build_version
COPY docker-entrypoint.sh /
RUN chmod 777 /docker-entrypoint.sh
CMD /docker-entrypoint.sh
Run Code Online (Sandbox Code Playgroud) docker-build ×10
docker ×9
dockerfile ×2
buildx ×1
chmod ×1
docker-image ×1
git ×1
git-clone ×1
ip ×1
linux ×1
node.js ×1
npm ×1
verbose ×1
windows-10 ×1