标签: alpine-linux

无法在 python3.7-alpine docker 镜像上安装 pendulum

我正在尝试在基于 python37-alpine 的 docker 映像中安装 pendulum 2.0.5,但它给了我以下错误:

\n\n
Installing dependencies from Pipfile.lock (0157fa)\xe2\x80\xa6\nAn error occurred while installing pendulum==2.0.5 --hash=sha256:1cde6e3c6310fb882c98f373795f807cb2bd6af01f34d2857e6e283b5ee91e09 --hash=sha256:485aef2089defee88607d37d5bc238934d0b90993d7bf9ceb36e481af41e9c66 --hash=sha256:57801754e05f30e8a7e4d24734c9fad82c6c3ec489151555f0fc66bb32ba6d6d --hash=sha256:7ee344bc87cb425b04717b90d14ffde14c1dd64eaa73060b3772edcf57f3e866 --hash=sha256:c460f4d8dc41ec3c4377ac1807678cd72fe5e973cc2943c104ffdeaac32dacb7 --hash=sha256:d3078e007315a959989c41cee5cfd63cfeeca21dd3d8295f4bc24199489e9b6c! Will try again.\nInstalling initially failed dependencies\xe2\x80\xa6\n[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 1874, in do_install\n[pipenv.exceptions.InstallError]:       keep_outdated=keep_outdated\n[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 1253, in do_init\n[pipenv.exceptions.InstallError]:       pypi_mirror=pypi_mirror,\n[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 859, in do_install_dependencies\n[pipenv.exceptions.InstallError]:       retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs\n[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 763, in batch_install\n[pipenv.exceptions.InstallError]:       _cleanup_procs(procs, not blocking, failed_deps_queue, retry=retry)\n[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 681, in _cleanup_procs\n[pipenv.exceptions.InstallError]:       raise exceptions.InstallError(c.dep.name, extra=err_lines)\n[pipenv.exceptions.InstallError]: [\'Collecting pendulum==2.0.5\', \'  Using cached …
Run Code Online (Sandbox Code Playgroud)

alpine-linux python-3.7 pendulum

5
推荐指数
1
解决办法
3721
查看次数

从高山图像中捕获 SIGTERM

我试图从 docker 实例捕获 SIGTERM 信号(基本上是在调用 docker stop 时),但找不到方法,因为我执行的每次尝试都有不同的结果。

以下是我的设置

Dockerfile

FROM gitlab/gitlab-runner:alpine

COPY ./start.sh /start.sh

ENTRYPOINT ["/start.sh"]
Run Code Online (Sandbox Code Playgroud)

启动文件

FROM gitlab/gitlab-runner:alpine

COPY ./start.sh /start.sh

ENTRYPOINT ["/start.sh"]
Run Code Online (Sandbox Code Playgroud)

现在我构建 docker 镜像

$ docker build -t dockertrapcatch .
Sending build context to Docker daemon  51.71kB
Step 1/3 : FROM gitlab/gitlab-runner:alpine
 ---> 9f8c39873bee
Step 2/3 : COPY ./start.sh /start.sh
 ---> Using cache
 ---> ebb3cac0c509
Step 3/3 : ENTRYPOINT ["/start.sh"]
 ---> Using cache
 ---> 7ab67fe5a714
Successfully built 7ab67fe5a714
Successfully tagged dockertrapcatch:latest
Run Code Online (Sandbox Code Playgroud)

运行泊坞窗

#!/bin/bash

deregister_runner() {
    echo …
Run Code Online (Sandbox Code Playgroud)

sigkill docker dockerfile gitlab-ci-runner alpine-linux

5
推荐指数
1
解决办法
6241
查看次数

Alpine 大小和 Docker 层

我正在公司设计应用程序的容器化。当我查看容器时,我看到很多关于 Alpine 的讨论。

讨论的基本内容围绕着 Alpine 的规模展开。Alpine 比其他 Linux 发行版小得多。Alpine 的大小为 5 MB(小得惊人),而 Ubuntu 的大小为 188 MB。

但我感到困惑的是为什么这真的很重要。包含操作系统的 docker 层应该只需要下载到机器一次(假设所有容器使用相同的基础镜像)。

例如,假设我有 50 个应用程序,每个应用程序放入 1 个容器中。它们每个都需要 50 MB,我在 docker 上运行它们。

  • 在 Alpine 上运行时,我的 50 个容器化应用程序将占用 2,505 MB 的磁盘空间。
  • 在 Ubuntu 上运行 50 个应用程序将占用 2,688 MB 磁盘空间。

这仅存在 7% 的差异。磁盘空间并不是很昂贵。因此,Ubuntu 运行所有容器所需的额外 183 MB 似乎并不重要。

但Alpine确实有很多人气。所以我不得不认为我错过了一些东西。也许它使用更少的内存?或者它更快?

Alpine Linux 发行版中的哪些功能促使 Docker 选择它作为其主要容器平台?

containers docker alpine-linux

5
推荐指数
1
解决办法
2432
查看次数

在 Alpine Docker 中安装 Docker

我有一个带有经典 Ubuntu 基础映像的 Dockerfile,我正在尝试减小其大小。这就是我使用 Alpine 底座的原因。

在我的 Dockerfile 中,我必须安装 Docker,因此 Docker in Docker。

FROM alpine:3.9 

RUN apk add --update --no-cache docker
Run Code Online (Sandbox Code Playgroud)

这很好用,我可以docker version在我的容器内运行,至少对于客户端来说是这样。因为对于服务器,我有一个经典的 Docker 错误:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Run Code Online (Sandbox Code Playgroud)

我知道在 Ubuntu 中安装 Docker 后我必须运行

usermod -a -G docker $USER
Run Code Online (Sandbox Code Playgroud)

但在阿尔卑斯山呢?我怎样才能避免这个错误?

附:

我的第一个想法是通过绑定安装等方式重新使用 Docker 套接字/var/run/docker.sock:/var/run/docker.sock,从而进一步减小图像的大小,因为我不必重新安装 Docker。

但是由于Dockerfile中不允许bind-mount,你知道我的想法是否可行以及如何实现?我知道这在 Docker-compose 中是可能的,但我只能使用 Dockerfile。

谢谢

docker dockerfile alpine-linux docker-in-docker

5
推荐指数
1
解决办法
8637
查看次数

在 Alpine Linux 中运行多个 PHP 版本

是否可以在 Alpine Linux 系统中直接运行多个版本的 PHP?喜欢同时使用 php 5.6、7.0 和 7.4?

在 ubuntu 中,这工作得很好,没有任何问题。例如,这可以通过使用 ppa 存储库来完成。之后可以通过 apt 包管理器轻松安装不同的 PHP 版本。

add-apt-repository ppa:ondrej/php
apt-get update
apt-get install php5.6
apt-get install php7.0
apt-get install php7.4

Run Code Online (Sandbox Code Playgroud)

有没有办法在 Alpine 上做到这一点?

php alpine-linux

5
推荐指数
1
解决办法
3704
查看次数

在 Alpine 上使用 pytorch

我在 alpine 有一个 docker 镜像,需要在其上使用 pytorch。不过按照pytorch网站上的说明,需要glibc才能运行,否则会报如下错误

import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/torch/__init__.py", line 189, in <module>
    _load_global_deps()
  File "/usr/lib/python3.7/site-packages/torch/__init__.py", line 142, in _load_global_deps
    ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
  File "/usr/lib/python3.7/ctypes/__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: Error relocating /usr/lib/python3.7/site-packages/torch/lib/libgomp-7c85b1e2.so.1: pthread_attr_setaffinity_np: symbol not found
Run Code Online (Sandbox Code Playgroud)

我尝试从https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-2.29-r0.apk安装 glibc ,但错误信息保持不变。

glibc docker alpine-linux pytorch

5
推荐指数
0
解决办法
1321
查看次数

使用 SSH 服务器设置 Docker 容器?

我想设置一个非常简约的 alpine linux docker 容器,具有以下功能:

  • 它运行一个 ssh 服务器
  • 它复制我选择的 SSH 公钥,然后我可以对其进行身份验证

我研究了各种选项,最后决定编写自己的小 Dockerfile。但是,我遇到了一些问题。

Dockerfile

FROM alpine:latest

RUN apk update
RUN apk upgrade
RUN apk add openssh-server

RUN mkdir -p /var/run/sshd
RUN mkdir -p /root/.ssh

ADD authorized_keys /root/.ssh/authorized_keys
ADD entrypoint.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh

EXPOSE 22
CMD ["/entrypoint.sh"]
Run Code Online (Sandbox Code Playgroud)

入口点.sh

#!/bin/sh
/usr/sbin/sshd -D
Run Code Online (Sandbox Code Playgroud)

授权密钥

ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBP8cIHIPgV9QoAaSsYNGHktiP/QnWfKPOeyzjujUXgQMQLBw3jJ1EBe04Lk3FXTMxwrKk3Dxq0VhJ+Od6UwzPDg=
Run Code Online (Sandbox Code Playgroud)

启动容器出现错误:sshd: no hostkeys available -- exiting。如何修复我的 Dockerfile,以确保 ssh 服务器正确运行并且authorized_keys 文件在那里。我缺少什么?

ssh containers sshd docker alpine-linux

5
推荐指数
1
解决办法
8470
查看次数

Issues with time() when running a C musl application in docker container on arm

My application is unable to handle time operations like time(2) when it runs in alpine docker container on an arm device.

What I have: I am building a native c application which is statically linked to musl with toolchain from musl.cc (arm-linux-musleabihf-gcc). I am using latest alpine container (without image tag).

How it behaves:

  • Running binary directly on arm device works as expected
  • Running in alpine container on x64 device works as expected
  • Running in alpine container on arm device …

c arm docker musl alpine-linux

5
推荐指数
1
解决办法
627
查看次数

如何使用 start 在 alpine docker 容器中加载 shell 别名

我编写了一个 DOCKER 文件,它使用私有改编的 alpine 镜像作为镜像,其中包含 nginx 服务器。\n注意:alpine 使用 zsh,而不是 bash。

\n

当我在容器中工作时,我喜欢有一些可用的 shell 别名,当它们丢失时,它会让我抓狂。因此,我将一个准备好的小文件复制到 /root/.profile,这有效。我可以查看该文件及其\xe2\x80\x99s 内容。但仅当我手动加载时,该文件才不会加载。~/.profile 在容器中,然后我就有了可用的别名。

\n

我需要做什么,才能在启动容器并连接到它\xe2\x80\x99s shell 后自动加载我的配置文件?

\n
FROM myprivatealpineimage/base-image-php:7.4.13\n\nARG TIMEZONE\n\nCOPY ./docker/shared/bashrc /root/.profile\n\nCOPY ./docker/shared/ /tmp/scripts/\nRUN chmod +x -R /tmp/scripts/ \\\n    && /tmp/scripts/set_timezone.sh ${TIMEZONE}\\\n    && apk update\\\n    && apk add --no-cache git\n\nRUN install-ext pecl/apcu pecl/imagick pecl/zip pecl/redis\nRUN apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing gnu-libiconv\nENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php\n\nWORKDIR /var/www\n
Run Code Online (Sandbox Code Playgroud)\n

docker alpine-linux

5
推荐指数
1
解决办法
8796
查看次数

错误:无法删除非 root 用户的权限:容器在 Google Cloud Compute Engine 上不断重新启动

我已经搜索过,但似乎找不到此错误的答案。创建新虚拟机时出现“错误:无法删除非 root 用户的权限”。

容器不断重新启动。它在我本地的 MacOS 机器上运行得很好。

我正在尝试在具有容器优化操作系统的 Google Compute Engine VM 上运行该映像。我正在使用 nginx、php-fpm 和 alpine。

Supervisord.conf 文件如下所示:

[supervisord]
nodaemon=true
logfile=/dev/null
logfile_maxbytes=0
pidfile=/run/supervisord.pid
user=root

[program:php-fpm]
command=php-fpm8 -F
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
priority=5
stdout_events_enabled=true
stderr_events_enabled=true

[program:nginx]
command=nginx -g 'daemon off;'
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=false
startretries=0
Run Code Online (Sandbox Code Playgroud)

有人也遇到过这个错误吗?

php nginx google-compute-engine docker alpine-linux

5
推荐指数
1
解决办法
5857
查看次数