skip to Main Content

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

3

Answers


  1. Chosen as BEST ANSWER

    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/


  2. 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
    
    Login or Signup to reply.
  3. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search