[英]Docker unable to locate package (wkhtmltopdf) while building
While troubleshooting I'm getting different errors:在进行故障排除时,我遇到了不同的错误:
...
Err:1 http://deb.debian.org/debian bullseye InRelease
Temporary failure resolving 'deb.debian.org'
...
I'm guessing it has something to do with my firewall settings(nftables) Running我猜这与我的防火墙设置(nftables)运行有关
docker run busybox nslookup google.com
gives me docker run busybox nslookup google.com
给我;; connection timed out; no servers could be reached
;; connection timed out; no servers could be reached
so the docker has no connection to the outside? ;; connection timed out; no servers could be reached
因此 docker 与外部没有连接?
Dev environment: Ubuntu 22.04
开发环境:
Ubuntu 22.04
Prod environment: debian 10.12 64bit / Linux 4.19.0-20-amd64
产品环境:
debian 10.12 64bit / Linux 4.19.0-20-amd64
FROM node:slim
# Install wkhtmltopdf
RUN apt-get update
RUN apt-get install -y wkhtmltopdf
RUN npm install -g pm2@latest
WORKDIR /var/api
COPY . .
RUN npm i
EXPOSE 10051-10053
# Start PM2 as PID 1 process
ENTRYPOINT ["pm2-runtime"]
CMD ["process.json"]
When building this file on my dev system (Ubuntu 22.04) it works fine.在我的开发系统 (Ubuntu 22.04) 上构建此文件时,它工作正常。
Building backend
Sending build context to Docker daemon 159.2kB
Step 1/10 : FROM node:slim
---> 6c8b32c67190
Step 2/10 : RUN apt-get update
---> Using cache
---> b28ad6ee8ebf
Step 3/10 : RUN apt-get install -y wkhtmltopdf
---> Running in 2f76d2582ac0
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package wkhtmltopdf
The command '/bin/sh -c apt-get install -y wkhtmltopdf' returned a non-zero code: 100
ERROR: Service 'backend' failed to build : Build failed
apt-get install -y wkhtmltopdf
solo on my server installs the package fine.apt-get install -y wkhtmltopdf
可以很好地安装 package。/etc/apt/sources.list
/etc/apt/sources.list
添加了不同的回购协议According to Docker docs :根据Docker 文档:
Using apt-get update alone in a RUN statement causes caching issues and subsequent apt-get install instructions fail.
在 RUN 语句中单独使用 apt-get update 会导致缓存问题,并且后续的 apt-get install 指令会失败。
So for your case, you should do:因此,对于您的情况,您应该这样做:
RUN apt-get update && apt-get install -y wkhtmltopdf
Instead of:代替:
RUN apt-get update
RUN apt-get install -y wkhtmltopdf
I found the solution, problem was nftables and docker.我找到了解决方案,问题是 nftables 和 docker。 Docker adds iptables rules to the ruleset, all I have to do was this:
Docker 将 iptables 规则添加到规则集中,我所要做的就是:
- use an ip and ipv6 table instead of inet
使用 ip 和 ipv6 表而不是 inet
- name all chains exactly as in iptables: INPUT, OUTPUT & FORWARD
完全按照 iptables 命名所有链:INPUT、OUTPUT & FORWARD
source: https://ehlers.berlin/blog/nftables-and-docker/来源: https ://ehlers.berlin/blog/nftables-and-docker/
Instead of fixing the problem, I downloaded .deb
and installed it, in my case with gdebi
but you can also use dpkg
.我没有解决问题,而是下载了
.deb
并安装了它,在我的例子中是gdebi
,但你也可以使用dpkg
。
RUN echo "### Install wkhtmltopdf ###" \
&& wget -nv -O /tmp/wkhtmltopdf.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_amd64.deb \
&& gdebi --non-interactive /tmp/wkhtmltopdf.deb
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.