- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试重写 Dockerfile ( https://github.com/orangefoil/rcssserver-docker/blob/master/Dockerfile ),以便它使用 alpine 而不是 ubuntu。目标是减小文件大小。
在原始图像中,robocup 足球服务器是使用 g++、flex、bison 等从头开始构建的。
FROM ubuntu:18.04 AS build
ARG VERSION=16.0.0
WORKDIR /root
RUN apt update && \
apt -y install autoconf bison clang flex libboost-dev libboost-all-dev libc6-dev make wget
RUN wget https://github.com/rcsoccersim/rcssserver/archive/rcssserver-$VERSION.tar.gz && \
tar xfz rcssserver-$VERSION.tar.gz && \
cd rcssserver-rcssserver-$VERSION && \
./bootstrap && \
./configure && \
make && \
make install && \
ldconfig
我试图在 alpine 上做同样的事情,不得不交换一些包裹:
FROM alpine:latest
ARG VERSION=16.0.0
WORKDIR /root
# Add basics first
RUN apk — no-cache update \
&& apk upgrade \
&& apk add autoconf bison clang-dev flex-dev boost-dev make wget automake libtool-dev g++ build-base
RUN wget https://github.com/rcsoccersim/rcssserver/archive/rcssserver-$VERSION.tar.gz
RUN tar xfz rcssserver-$VERSION.tar.gz
RUN cd rcssserver-rcssserver-$VERSION && \
./bootstrap && \
./configure && \
make && \
make install && \
ldconfig
不幸的是,我的版本还不行。它失败了
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lrcssclangparser
从我目前发现的情况来看,如果没有安装开发包(参见
ld cannot find an existing library ),可能会发生这种情况,但是我更改为可以找到它们的开发包,但仍然没有运气。
最佳答案
您应该使用 multi-stage build 将其分解。 .在您现在正在构建的镜像中,最终镜像包含 C 工具链以及那些 -dev
的所有开发库和头文件。包安装;您不需要任何这些来实际运行构建的应用程序。基本思想是完全按照您现在的方式构建应用程序,但之后是 COPY
只有将构建的应用程序放入具有较少依赖项的新镜像中。
这看起来像这样(未经测试):
FROM ubuntu:18.04 AS build
# ... exactly what's in the original question ...
FROM ubuntu:18.04
# Install the shared libraries you need to run the application,
# but not -dev headers or the full C toolchain. You may need to
# run `ldd` on the built binary to see what exactly it needs.
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
apt-get install --assume-yes --no-install-recommends \
libboost-atomic1.65.1 \
libboost-chrono1.65.1 \
# ... more libboost-* libraries as required ...
# Get the built application out of the original image.
# Autoconf's default is to install into /usr/local, and in a
# typical Docker base image nothing else will be installed there.
COPY --from=build /usr/local /usr/local
RUN ldconfig
# Describe how to run a container.
EXPOSE 12345
CMD ["/usr/local/bin/rcssserver"]
与 C 工具链、头文件和构建时库的大小相比,Alpine 和 Ubuntu 镜像之间的差异非常小,而且 Alpine 具有充分记录的库兼容性问题,其最小的 libc 实现。
关于docker - 如何在 ubuntu 上构建基于 alpine 的类似 docker 镜像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64866563/
所以最近(9 月 5 日)Alpine Linux 软件包仓库更新为 postgresql-client 12.4 我在我的 Dockerfile ( apk add postgresql-clien
当我运行 apk add --update ab 时出现错误: bash-4.3# apk add --update ab fetch http://dl-cdn.alpinelinux.org/al
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 9 个月前关闭。 Improve t
我有一个在 Alpine 发行版上运行的 docker 镜像,为了让我的一个要求工作 - pocketsphinx==0.1.15,我必须在我的 DockerFile 中安装一些依赖项: FROM p
我已按照以下步骤创建自定义 rootfs 镜像以使用 firecracker 启动:- https://github.com/firecracker-microvm/firecracker/blob/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我正在使用 alpine(最低 3.5)并且我需要使用 nodeJS 4.8.4 Docker 文件 FROM alpine:3.5 RUN apk add --update nodejs=4.8.4
使用 ruby-2.6.6-alpine 的 Docker 镜像创建了一个 498mb 的镜像大小。但是,当我降级到 ruby-2.6.5-alpine 时,它又回到了 266mb。 2.
我尝试在php:7.0-fpm-alpine上安装bz2扩展(基于Alpine 3.4): FROM php:7.0-fpm-alpine RUN docker-php-ext-install bz2
1、运行 fonts ,打开字体文件夹,找到要用的字体文件; 2、修改Dockerfile,例如: ?
我有这个Dockerfile ... FROM keymetrics/pm2:latest-alpine RUN apk update && \ apk upgrade && \ ap
我已经阅读了很多有关Docker容器和Unikernel的知识,以及如何在自己的应用程序中运行轻量级环境。 我知道Linux容器和Unikernel是不同的东西,因为第一个是内核功能(例如 names
我有一个 docker 镜像 nginx:stable-alpine,我需要使用 nginx-extras 为了使用 rewrite_by_lua指示。 我尝试通过 apk add --cached
堆高车 我正在使用Docker容器化我的应用程序。在下面的stage中,我尝试使用UPX对其进行打包。 FROM alpine:3.8 AS compressor # Version of upx t
我在CI / CD机器上使用Alpine linux。下面的docker文件: FROM node:10.15-alpine RUN npm i -g sequelize sequelize-cli
我正在尝试使用 The Badass Runtime Plugin 创建自定义运行时图像然后在 Alpine 上执行它。但它失败并显示以下错误消息。 jibcmd_1 | /bin/sh: exec
如何为所有语言安装字体?这是我的工作,但是Chrome中没有日语字体。 从此图像:https://github.com/Zenika/alpine-chrome/blob/master/Dockerf
是否可以在 Alpine Linux 中的 less 命令上启用鼠标滚动? 我尝试过使用 export LESS=-R 但没有任何作用。 最佳答案 Alpine 上默认的 less 由 BusyBox
我正在尝试在 alpine 中安装一个包,在本例中我指定了“jasper-dev”,但我和其他许多人都遇到过这种情况。我在终端中得到的输出是: / # apk add jasper-dev ERROR
当尝试安装 pdftk apk 时抛出此错误。 ERROR: unsatisfiable constraints: pdftk (missing): required by: world[
我是一名优秀的程序员,十分优秀!