編輯
在進行故障排除時,我遇到了不同的錯誤:
...
Err:1 http://deb.debian.org/debian bullseye InRelease
Temporary failure resolving 'deb.debian.org'
...
我猜它與我的防火墻設定(nftables)有關運行docker run busybox nslookup google.com
給了我
;; connection timed out; no servers could be reached,所以 docker 沒有與外部的連接?
系統
開發環境:Ubuntu 22.04
生產環境:debian 10.12 64bit / Linux 4.19.0-20-amd64
我的節點后端檔案夾中的 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"]
在我的開發系統(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可以很好地安裝軟體包。 - 向
/etc/apt/sources.list - 我知道它的包https://packages.debian.org/buster/wkhtmltopdf (?)
- 一些故障排除。
uj5u.com熱心網友回復:
根據Docker 檔案:
在 RUN 陳述句中單獨使用 apt-get update 會導致快取問題,并且后續的 apt-get install 指令會失敗。
因此,對于您的情況,您應該這樣做:
RUN apt-get update && apt-get install -y wkhtmltopdf
代替:
RUN apt-get update
RUN apt-get install -y wkhtmltopdf
uj5u.com熱心網友回復:
我找到了解決方案,問題是 nftables 和 docker。Docker 將 iptables 規則添加到規則集中,我所要做的就是:
- 使用 ip 和 ipv6 表而不是 inet
- 完全按照 iptables 命名所有鏈:INPUT、OUTPUT & FORWARD
來源:https ://ehlers.berlin/blog/nftables-and-docker/
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/492914.html
標籤:linux 码头工人 ubuntu Debian 易于
