我正在尝试在 docker 中的 Alpine 上安装节点画布(https://github.com/Automattic/node-canvas)。
这些是(部分)我的 Dockerfile:
# Use node/alpine image for final build
FROM keymetrics/pm2:latest-alpine as app
# install dependencies for canvas
RUN apk --no-cache --virtual .build-deps add \
python \
make \
g++ \
gcc \
&& apk --no-cache --virtual .canvas-build-deps add \
build-base \
cairo-dev \
jpeg-dev \
pango-dev \
giflib-dev \
pixman-dev \
pangomm-dev \
libjpeg-turbo-dev \
freetype-dev \
&& apk --no-cache add \
pixman \
cairo \
pango \
giflib
RUN apk add …Run Code Online (Sandbox Code Playgroud) 我想使用 apk 在 Alpine Linux 中安装一些 Python 包。下面我以 numpy 为例。
文件
FROM python:3-alpine
RUN apk add --update py3-numpy
Run Code Online (Sandbox Code Playgroud)
我构建了我的 Docker 镜像
$ docker build -t python-numpy .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM python:3-alpine
---> 930a7e894675
Step 2/2 : RUN apk add --update py3-numpy
---> Running in b30470090cde
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
(1/6) Installing libgcc (8.3.0-r0)
(2/6) Installing libquadmath (8.3.0-r0)
(3/6) Installing libgfortran (8.3.0-r0)
(4/6) Installing openblas (0.3.6-r0)
(5/6) Installing python3 (3.7.3-r0)
(6/6) Installing py3-numpy …Run Code Online (Sandbox Code Playgroud) 我是 Docker 的新手。我想通过使用 make 命令构建一个 C++ 库来构建一个 docker 镜像。我在 Dockerfile 中这样做的方式是
Dockerfile 代码写在下面。
我面临的问题是,即使删除了源代码,最终的图像尺寸还是很大。
由于 Dockerfile 的每一行都创建了不同的层,因此有一种方法可以使用 curl 或 wget 下载源代码,然后删除同一层中的源代码。但我不喜欢这个解决方案。
FROM alpine
RUN apk update && apk add <required_packages>
COPY source_code /tmp/source_code
RUN make -C /tmp/source_code && \
mkdir /libraries/
cp /tmp/lib/* /libraries/
rm -rf /tmp/*
Run Code Online (Sandbox Code Playgroud)
我只想最小化最终图像的大小。这是我这样做的正确方法还是有更好的方法?请帮忙。
我有一个依赖项,package.json它本身具有以下依赖项:
"node-rdkafka": "^2.5.0",
使用nvm我的本地机器上,我的节点版本设置8.9.1,我的npm版本是5.5.1,我可以成功运行
npm install node-rdkafka@2.7.1
但是当npm install从我的 docker 镜像中运行相同的东西(即)时:
FROM node:10.13.0-alpine 或者 FROM node:8.9.1-alpine
我收到以下错误:
npm ERR! notsup Unsupported engine for node-rdkafka@2.7.1: wanted: {"node":">=12.0.0"} (current: {"node":"10.13.0","npm":"6.4.1"})
npm ERR! notsup Not compatible with your version of node/npm: node-rdkafka@2.7.1
npm ERR! notsup Not compatible with your version of node/npm: node-rdkafka@2.7.1
npm ERR! notsup Required: {"node":">=12.0.0"}
npm ERR! notsup Actual: {"npm":"6.4.1","node":"10.13.0"}
Run Code Online (Sandbox Code Playgroud)
关于这种不一致的任何想法?
我显然不需要这么高的节点版本。但它说我愿意。
我正在尝试使用Alpine图像来处理一些Postgres数据库创建/准备工作。在容器内,我正在运行以下命令:
createdb -e -O ${DB_USER} ${DB_NAME}
psql -e -d ${DB_NAME} -c "CREATE EXTENSION postgis;"
Run Code Online (Sandbox Code Playgroud)
第一行工作正常,但第二行不行。
我已经用两个 docker 构建尝试过这个:
FROM alpine:3.6
RUN apk add -U postgresql
COPY ./db-creator.sh /db-creator.sh
CMD ["./db-creator.sh"]
Run Code Online (Sandbox Code Playgroud)
这张图片给了我以下错误:
CREATE EXTENSION postgis;
ERROR: could not open extension control file "/usr/share/postgresql/10/extension/postgis.control": No such file or directory
Run Code Online (Sandbox Code Playgroud)
我没有尝试PostGIS直接安装,因为本论坛中有人坚持认为apk add -U postgresql裸Alpine图像就足够了。
FROM postgres:9.6.4-alpine
RUN apk add -U postgresql
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN …Run Code Online (Sandbox Code Playgroud) 我的 dockerfile 看起来像这样:
FROM alpine
RUN apk add --no-cache \
ca-certificates \
curl \
python \
py-pip
RUN pip install awscli
# remaining code...
Run Code Online (Sandbox Code Playgroud)
但是当我构建它时,我收到以下错误日志:
RUN apk add --no-cache ca-certificates curl python py-pip
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
python (missing):
required by: world[python]
The command '/bin/sh -c apk add --no-cache ca-certificates curl python py-pip' returned a non-zero code: 1
Run Code Online (Sandbox Code Playgroud)
我发现了一些描述相同错误的问题,但解决方案对我没有帮助。
我需要提到python版本吗?我真的很想用来安装最新版本。
语境
我有一个基于postgres:11-alpine过去工作过的 dockerfile (可能是自上次构建以来的几个月),其定义如下:
FROM postgres:11-alpine
RUN apk update
# install aws cli
# taken from: https://github.com/anigeo/docker-awscli/blob/master/Dockerfile
RUN \
apk -Uuv add groff less python py-pip && \
pip install awscli && \
apk --purge -v del py-pip && \
rm /var/cache/apk/*
Run Code Online (Sandbox Code Playgroud)
我最近尝试在升级到 postgres 12 之前重建它,但图像构建失败:
ERROR: unsatisfiable constraints:
python (missing):
required by: world[python]
Run Code Online (Sandbox Code Playgroud)
我猜python因为 YOLO ,包裹现在不见了?无论如何,我尝试python3通过将 docker 文件更改为:
RUN \
apk -Uuv add groff less python3 py-pip && \
pip install awscli && …Run Code Online (Sandbox Code Playgroud) 我想在高山容器中添加terraform版本0.12.21,但我只能0.11.0使用apk. 如果我尝试将其添加为所需版本,则会出现以下错误:
/ # apk upgrade terraform==0.12.21-r0
OK: 192 MiB in 66 packages
/ # apk add terraform==0.12.21-r0
ERROR: unsatisfiable constraints:
terraform-0.11.0-r0:
breaks: world[terraform=0.12.21-r0]
Run Code Online (Sandbox Code Playgroud)
如何修复此 apk 错误?
如何解决以下错误?
尝试pipenv在 Alpine上安装时:
pip3 install pipenv
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Installing collected packages: distlib, virtualenv, pipenv
Attempting uninstall: distlib
Found existing installation: distlib 0.3.0
ERROR: Cannot uninstall 'distlib'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Run Code Online (Sandbox Code Playgroud)
Python 版本:3.8.3
pip3 版本:20.2.2
Alpine 版本:3.12(Linux 5.4.43-1-virt #2-Alpine SMP Thu, 28 May 2020 20:13:48 UTC x86_64 Linux)
我只是偶然发现了用于 alpine 的 tzdata2020c 包的一个错误。在 2020 年 10 月 25 日下星期日的夏令时计划更改后,它不会计算欧洲/柏林的正确时间。 tzdata2020c 版本使用 CEST,例如 2020 年 10 月 31 日和欧洲/柏林时区,而 CET 是正确的。
有谁知道如何手动添加新版本的 tzdata2020d 数据库,该数据库可在此处获得。
我用 Go 编写的应用程序在 2020 年 10 月 31 日使用 tzdata2020c 错误地将 CEST 用于欧洲/柏林:

同一应用程序在 2020 年 10 月 31 日使用 tzdata2020a 正确使用了欧洲/柏林的 CET:

alpine-linux ×10
docker ×7
python ×3
dockerfile ×2
aws-cli ×1
go ×1
makefile ×1
node-canvas ×1
node.js ×1
npm ×1
numpy ×1
nvm ×1
pip ×1
pipenv ×1
postgis ×1
postgresql ×1
terraform ×1
tzdata ×1