如何将 dos2unix 添加到基于 Alpine 的 docker 容器中?

How can I add dos2unix to an Alpine based docker container?

我有以下 dockerfile:

FROM haproxy:alpine

RUN apk --update add bash && apk --no-cache add dos2unix rsyslog supervisor wget curl ruby which py-setuptools py-pip && pip install awscli && chmod +x /*.sh

COPY *haproxy.cfg /etc/
COPY supervisord.ini /etc/
COPY rsyslog.conf /etc/

COPY entrypoint.sh /
RUN dos2unix /entrypoint.sh && apt-get --purge remove -y dos2unix

ENTRYPOINT ["/entrypoint.sh"]

EXPOSE 9999

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.ini"]

然而,当我构建这个时,我得到:

fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  dos2unix (missing):
    required by: world[dos2unix]

不过我可以看到这里存在包:https://pkgs.alpinelinux.org/packages?name=dos2unix&branch=&repo=&arch=&maintainer=

我做错了什么?

根据您自己的 link,dos2unix(此时,2017 年 2 月)仅在 testing,而不在 maincommunity。来自 the relevant documentation --

If you only have the main repository enabled in your configuration, apk will not include packages from the other repositories. To install a package from the edge/testing repository without changing your repository configuration file, use the command below. This will tell apk to use that particular repository.

apk add cherokee --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted

在这种情况下,您需要将 dos2unix 替换为 cherokee