我尝试git-lfs在 Docker alpine 映像中安装,但收到一条错误消息,指示:
错误:无法满足的约束:
git-lfs(丢失):
需要:世界[git-lfs]
似乎存在许多与 apk 找不到软件包相关的问题(请参阅此处和那里),并且在许多情况下,这些问题已通过--no-cache使用apk add. 但我没有那么幸运,无法理解这个错误的根源,特别是考虑到 git-lfs 在alpine repo中是最新的。
以下小 Dockerfile 应该会重现该错误:
FROM alpine:3.4
RUN apk update && apk add --no-cache \
build-base \
git \
git-lfs
Run Code Online (Sandbox Code Playgroud) 我是 Docker 新手,一直在尝试将 python 脚本包装在容器中,但在我的对接 alpine 实例上安装 scipy 0.17.0(作为 scikit-learn 的依赖项)时遇到错误我一直没能找到答案。
我的 Dockerfile:
FROM python:alpine
COPY . /app
WORKDIR /app
RUN apk add --no-cache python3-dev libstdc++ && \
apk add --no-cache g++ && \
ln -s /usr/include/locale.h /usr/include/xlocale.h
RUN pip3 install -r requirements.txt
CMD python ./python_script.py
Run Code Online (Sandbox Code Playgroud)
我的requirements.txt文件:
numpy==1.16.5
pandas==0.25.2
scikit-learn==0.21.3
Run Code Online (Sandbox Code Playgroud)
输出:
Sending build context to Docker daemon 1.097GB
Step 1/7 : FROM python:alpine
---> 204216b3821e
Step 2/7 : COPY . /app
---> 1e06520a2b68
Step 3/7 : WORKDIR /app
---> Running …Run Code Online (Sandbox Code Playgroud) 我正在尝试在基于 python37-alpine 的 docker 映像中安装 pendulum 2.0.5,但它给了我以下错误:
\n\nInstalling 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) 我试图从 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) 我正在公司设计应用程序的容器化。当我查看容器时,我看到很多关于 Alpine 的讨论。
讨论的基本内容围绕着 Alpine 的规模展开。Alpine 比其他 Linux 发行版小得多。Alpine 的大小为 5 MB(小得惊人),而 Ubuntu 的大小为 188 MB。
但我感到困惑的是为什么这真的很重要。包含操作系统的 docker 层应该只需要下载到机器一次(假设所有容器使用相同的基础镜像)。
例如,假设我有 50 个应用程序,每个应用程序放入 1 个容器中。它们每个都需要 50 MB,我在 docker 上运行它们。
这仅存在 7% 的差异。磁盘空间并不是很昂贵。因此,Ubuntu 运行所有容器所需的额外 183 MB 似乎并不重要。
但Alpine确实有很多人气。所以我不得不认为我错过了一些东西。也许它使用更少的内存?或者它更快?
Alpine Linux 发行版中的哪些功能促使 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。
谢谢
我想设置一个非常简约的 alpine linux docker 容器,具有以下功能:
我研究了各种选项,最后决定编写自己的小 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 文件在那里。我缺少什么?
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:
我编写了一个 DOCKER 文件,它使用私有改编的 alpine 镜像作为镜像,其中包含 nginx 服务器。\n注意:alpine 使用 zsh,而不是 bash。
\n当我在容器中工作时,我喜欢有一些可用的 shell 别名,当它们丢失时,它会让我抓狂。因此,我将一个准备好的小文件复制到 /root/.profile,这有效。我可以查看该文件及其\xe2\x80\x99s 内容。但仅当我手动加载时,该文件才不会加载。~/.profile 在容器中,然后我就有了可用的别名。
\n我需要做什么,才能在启动容器并连接到它\xe2\x80\x99s shell 后自动加载我的配置文件?
\nFROM 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\nRun Code Online (Sandbox Code Playgroud)\n Alpine 中是否可以安装有效的 CloudWatch 代理包?我们希望在 Alpine 上为 CloudWatch Agent 构建自定义 docker,但可以在https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/download-cloudwatch-agent-commandline.html中进行下载中的可用下载似乎不起作用(我尝试了一些 deb 或 rpm)。
一些错误:无法安装下载的 deb 文件:
/ # dpkg -i -E amazon-cloudwatch-agent.deb
dpkg: error processing archive amazon-cloudwatch-agent.deb (--install):
package architecture (amd64) does not match system (musl-linux-amd64)
Run Code Online (Sandbox Code Playgroud)
并无法安装下载的 rpm 文件:
/ # rpm -U amazon-cloudwatch-agent.rpm
error: Failed dependencies:
/bin/sh is needed by amazon-cloudwatch-agent-1.247347.6b250880-1.x86_64
Run Code Online (Sandbox Code Playgroud)
CloudWatch Agent 是否支持 Alpine 有明确的答案吗?显然它是由 CloudWatch Log Agent 支持的。
alpine-linux ×10
docker ×8
dockerfile ×3
containers ×2
arm ×1
c ×1
musl ×1
pendulum ×1
python-3.7 ×1
scipy ×1
sigkill ×1
ssh ×1
sshd ×1