所以我正在使用 Alpine Linux,它使用 musl 与 glibc。
我发现由于这个选择,我无法运行 Oracle Java 或在 glibc 下构建的静态 go 二进制文件。
musl 是否应该与更广泛使用的 glibc 兼容,或者您是否需要针对它重新编译?(我真的不希望甲骨文这样的大公司这么做!)
如果我为当前使用的 Flask 部署构建 docker 映像:
Dockerfile
FROM python:3.6-alpine
COPY . /app
WORKDIR /app
RUN apk add --virtual build-deps gcc python-dev musl-dev && \
apk add postgresql-dev
RUN pip install pipenv
RUN pipenv install --system --deploy
EXPOSE 5005
ENV FLASK_APP=app/__init__.py
ENV FLASK_RUN_PORT=5005
CMD flask run --host=0.0.0.0
Run Code Online (Sandbox Code Playgroud)
不幸的是,这会导致容器大小约为 500MB。原始 Alpine 图像约为 40MB。主要的大小增加来自于安装 psycopg2 和 gcc(psycopg2 需要)。
我真的很想减小该图像的尺寸。任何想法表示赞赏。
我正在尝试通过多阶段 docker 构建安装 ffmpeg
这是包含 ffmpeg 二进制文件的 ffmpeg 图像
FROM jrottenberg/ffmpeg
Run Code Online (Sandbox Code Playgroud)
这是我运行网络服务器所需的 pm2 映像
FROM keymetrics/pm2:8-alpine
Run Code Online (Sandbox Code Playgroud)
我将 bin 复制到当前映像中,可以看到 ffmpeg、ffserver 和 ffprobe 都存在于 /usr/local/bin 中。
COPY --from=0 /usr/local /usr/local
Run Code Online (Sandbox Code Playgroud)
复制命令似乎成功,因为当我以交互方式运行容器时这些文件存在。
$# which ffmpeg
/usr/local/bin/ffmpeg
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试运行垃圾箱时,它说找不到该命令。
$# ffmpeg --version
/bin/sh: ffmpeg: not found
Run Code Online (Sandbox Code Playgroud) 我正在通过安装一些绘图包来创建自定义 Dockerfile。我无法在 Dockerfile 中安装 libgdiplus-dev 包。我尝试在 Dockerfile 中添加镜像 URL https://pkgs.alpinelinux.org/package/edge/testing/armhf/libgdiplus- (可以在此 URL 中找到镜像) dev 但没有帮助。
FROM alpine:3.7
RUN apk add --no-cache libgdiplus-dev
Run Code Online (Sandbox Code Playgroud)
运行上面的命令最终我说
libgdiplus-dev (missing):
required by: world[libgdiplus-dev]
Run Code Online (Sandbox Code Playgroud) 最近,curl 发布了新版本 7.66.0。当我在alpine的curl升级到这个版本时。当我使用任何 URL 运行curl 时,我总是收到以下错误。
curl_multi_poll:找不到符号
它在之前的版本 7.65.3 上运行良好。我是否需要升级其他一些库或其他东西才能使其工作?
在docker中使用WP CLI时,我需要以root身份执行它。我需要--allow-root直接在 .bashrc 中添加该标志,我试图找出它不起作用的原因。
FROM webdevops/php-dev:7.3
# configure postfix to use mailhog
RUN postconf -e "relayhost = mail:1025"
# install wp cli
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
chmod +x wp-cli.phar && \
mv wp-cli.phar /usr/local/bin/wp && \
echo 'wp() {' >> ~/.bashrc && \
echo '/usr/local/bin/wp "$@" --allow-root' >> ~/.bashrc && \
echo '}' >> ~/.bashrc
WORKDIR /var/www/html/
Run Code Online (Sandbox Code Playgroud)
我的.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# Note: PS1 and umask are already set in /etc/profile. …Run Code Online (Sandbox Code Playgroud) 我正在尝试在从 Alpine 3.7 基础映像构建的 docker 容器中编译一个程序。该程序使用argp.h, 并将其包含为 #include <argp.h>. 我已经安装了 argp-standalone 并验证它是否已添加到映像中。该文件argp.h位于usr/include,但是当我使用以下命令编译程序时:
gcc -W -Wall -Wextra -I/usr/include -c -o progname.o progname.c
gcc -largp -o progname progname.o
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
progname.o: In function `parse_opt':
progname.c:(.text+0x4c9): undefined reference to `argp_failure'
progname.c:(.text+0x50f): undefined reference to `argp_failure'
progname.c:(.text+0x555): undefined reference to `argp_failure'
progname.c:(.text+0x59b): undefined reference to `argp_failure'
progname.c:(.text+0x5ce): undefined reference to `argp_error'
progname.c:(.text+0x5f4): undefined reference to `argp_error'
progname.o: In function `main':
progname.c:(.text+0x1397): undefined reference to `argp_parse'
collect2: error: ld …Run Code Online (Sandbox Code Playgroud) 当我在 bash 模式下运行容器时,我想将用户www-data添加为默认用户。
目前,当我输入 WHOAMI 时,它显示root用户,但我需要www-data用户,如何在 docker 中执行此操作。
这是我的泊坞窗文件:
FROM php:7.2-fpm-alpine
LABEL maintainer="y.ghorecha@abc.de" \
muz.customer="xxx" \
muz.product="WIDC" \
container.mode="production"
#https://pkgs.alpinelinux.org/packages
RUN apk add --no-cache --virtual .deps autoconf tzdata build-base libzip-dev mysql-dev gmp-dev \
libxml2-dev libpng-dev zlib-dev freetype-dev jpeg-dev icu-dev openldap-dev libxslt-dev &&\
docker-php-ext-install zip xml mbstring json intl gd pdo pdo_mysql iconv soap \
dom gmp fileinfo sockets bcmath mysqli ldap xsl &&\
echo 'date.timezone="Europe/Berlin"' >> "${PHP_INI_DIR}"/php.ini &&\
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime &&\
echo 'Europe/Berlin' > …Run Code Online (Sandbox Code Playgroud) 我使用 alpine-3.7 和 ruby-2.5 (bundler-2.1.2) 创建了一个 docker 映像。在安装 ruby gems 时,使用bundle install,我收到以下错误。
Fetching jaro_winkler 1.5.2
Installing jaro_winkler 1.5.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
An error occurred while installing jaro_winkler (1.5.2), and Bundler cannot continue.
Make sure that `gem install jaro_winkler -v '1.5.2' --source 'https://testrepos.net/api/gems/rubygems/'` succeeds before bundling
Run Code Online (Sandbox Code Playgroud)
我也尝试过gem install jaro_winkler -v '1.5.2' --source 'https://testrepos.net/api/gems/rubygems/',但出现以下错误。
Fetching jaro_winkler-1.5.2.gem
Building native extensions. This could take a while...
ERROR: Error installing jaro_winkler:
ERROR: Failed …Run Code Online (Sandbox Code Playgroud) 问:在我的 docker 容器中,我使用 apline linux 系统,该系统已预安装 gcc
应用程序信息:
bash-4.4# apk info
....
gcc
Run Code Online (Sandbox Code Playgroud)
但是当我安装 multidict 时,由于 gcc 错误而失败
bash-4.4# pip install multidict
Collecting multidict
Using cached https://files.pythonhosted.org/packages/84/96/5503ba866d8d216e49a6ce3bcb288df8a5fb3ac8a90b8fcff9ddcda32568/multidict-4.7.3.tar.gz
Building wheels for collected packages: multidict
Building wheel for multidict (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-79jceuft/multidict/setup.py'"'"'; __file__='"'"'/tmp/pip-install-79jceuft/multidict/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-57k4lw21 --python-tag cp37
cwd: /tmp/pip-install-79jceuft/multidict/
....
/usr/local/include/python3.7m/Python.h:11:20: fatal error: limits.h: No such file …Run Code Online (Sandbox Code Playgroud)