docker无法找到包装(WKHTMLTOPDF)

发布于 2025-02-08 06:19:57 字数 1736 浏览 2 评论 0原文

在故障排除时编辑

我会遇到不同的错误:

...
Err:1 http://deb.debian.org/debian bullseye InRelease
  Temporary failure resolving 'deb.debian.org'
...

我猜这与我的防火墙设置有关(nftables) 运行

docker运行busybox nslookup google.com 给我
;;连接时间出现;无法达到服务器,因此Docker与外部没有连接?

系统

开发环境:Ubuntu 22.04
产品环境:debian 10.12 64bit / linux 4.19.0-20-AMD64 < / code>

dockerfile在我的节点后端文件夹内

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"]

构建此文件时,在我的dev System(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

我尝试过

EDIT

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
docker run busybox nslookup google.com
gives me
;; connection timed out; no servers could be reached so the docker has no connection to the outside?

Systems

Dev environment: Ubuntu 22.04
Prod environment: debian 10.12 64bit / Linux 4.19.0-20-amd64

Dockerfile inside my node backend folder

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.

However, deploying it go my server and letting it build, I get this output:

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

What I have tried

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

缘字诀 2025-02-15 06:19:57

根据 docker docs

在运行语句中仅使用APT-GET更新会导致缓存问题,然后随后的APT-GET安装说明失败。

因此,对于您的情况,您应该这样做:

RUN apt-get update && apt-get install -y wkhtmltopdf 

而不是:

RUN apt-get update
RUN apt-get install -y wkhtmltopdf

According to Docker docs:

Using apt-get update alone in a RUN statement causes caching issues and subsequent apt-get install instructions fail.

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
把时间冻结 2025-02-15 06:19:57

我发现了解决方案,问题是Nftables和Docker。
Docker在规则集中添加了iPtables规则,我要做的就是这样:

  • 使用IP和IPv6表代替INET
  • 所有链的名称与Iptables:输入,输出&amp;向前

来源:

I found the solution, problem was nftables and docker.
Docker adds iptables rules to the ruleset, all I have to do was this:

  • use an ip and ipv6 table instead of inet
  • name all chains exactly as in iptables: INPUT, OUTPUT & FORWARD

source: https://ehlers.berlin/blog/nftables-and-docker/

玩套路吗 2025-02-15 06:19:57

在我的情况下,我没有解决问题,而是下载了.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

Instead of fixing the problem, I downloaded .deb and installed it, in my case with gdebi but you can also use 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文