You are not logged in.

#1 2024-11-16 21:16:55

JoMaZu787
Member
Registered: 2024-05-29
Posts: 13

[Solved] Docker kills apt-get

When I try to build this Dockerfile:

FROM python:3.12

RUN apt update && apt install -y gcc libpq-dev
RUN pip install sqlalchemy psycopg2 nicegui

WORKDIR /app
ADD *.py .

ENTRYPOINT ["python3", "/app/main.py"]

I get this error:

=> ERROR [2/5] RUN apt update && apt install -y gcc libpq-dev                                        2.6s
------
 > [2/5] RUN apt update && apt install -y gcc libpq-dev:
0.265 
0.265 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
0.265 
0.350 Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
0.397 Get:2 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
0.414 Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
0.451 Get:4 http://deb.debian.org/debian bookworm/main amd64 Packages [8789 kB]
0.915 Get:5 http://deb.debian.org/debian bookworm-updates/main amd64 Packages [2468 B]
0.916 Get:6 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages [204 kB]
1.649 Fetched 9250 kB in 1s (6787 kB/s)
1.649 Reading package lists...
1.991 Building dependency tree...
2.058 Reading state information...
2.066 2 packages can be upgraded. Run 'apt list --upgradable' to see them.
2.069 
2.069 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
2.069 
2.070 Reading package lists...
2.422 Building dependency tree...
2.500 Reading state information...
2.585 gcc is already the newest version (4:12.2.0-3).
2.585 Suggested packages:
2.585   postgresql-doc-15
2.598 The following packages will be upgraded:
2.599   libpq-dev libpq5
2.605 Killed
------
Dockerfile:3
--------------------
   1 |     FROM python:3.12
   2 |     
   3 | >>> RUN apt update && apt install -y gcc libpq-dev
   4 |     RUN pip install sqlalchemy psycopg2 nicegui
   5 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c apt update && apt install -y gcc libpq-dev" did not complete successfully: exit code: 137

I do not think this is a memory issue, as the system RAM usage does not increase when running the build.
I am running docker from the normal repos, not docker-desktop.
I have tried running the apt-get commands one after the other instead of chaining, and the crash always happens when installing libpq-dev.

Last edited by JoMaZu787 (2024-11-21 15:51:37)

Offline

#2 2024-11-17 03:23:00

ratemisia
Member
Registered: 2024-11-17
Posts: 3

Re: [Solved] Docker kills apt-get

apt? Debian-bookworm repository? You might be in the wrong help forum, @JoMaZu787... You're on Arch Linux, correct - and not, say, Ubuntu or Mint or MX or Debian? If so, those other distros have lovely forums full of lovely people who would be much better equipped to handle this issue than we are. hmm

Last edited by ratemisia (2024-11-17 03:31:44)

Offline

#3 2024-11-17 10:44:40

JoMaZu787
Member
Registered: 2024-05-29
Posts: 13

Re: [Solved] Docker kills apt-get

The apt-get command is being run in the container, which is based on Debian. I am running Arch.

Last edited by JoMaZu787 (2024-11-17 11:10:26)

Offline

#4 2024-11-17 14:17:50

seth
Member
Registered: 2012-09-03
Posts: 58,974

Re: [Solved] Docker kills apt-get

exit code: 137 still means the process gets sigkill'ed - the reasons for that are most likely OOM or  timeout, so try to raise the docker memory limit and timeout into the absurd and see which one mitigates that step.

Offline

#5 2024-11-17 15:49:51

JoMaZu787
Member
Registered: 2024-05-29
Posts: 13

Re: [Solved] Docker kills apt-get

I've tried

docker build --memory 8G app

but it gives the same error, and I'm not sure how to change the timeout, if there is any.

Offline

#6 2024-11-17 16:10:43

seth
Member
Registered: 2012-09-03
Posts: 58,974

Re: [Solved] Docker kills apt-get

Not the --memory parameter, see https://stackoverflow.com/a/45468671
Edit: also https://wiki.archlinux.org/title/Docker … ds_too_low in case the quotas there are too strict)

Last edited by seth (2024-11-17 16:12:57)

Offline

#7 2024-11-17 16:25:31

JoMaZu787
Member
Registered: 2024-05-29
Posts: 13

Re: [Solved] Docker kills apt-get

The answers in the linked stackoverflow question appear to be either irrelevant (referring to running in a vm with limited memory or on docker desktop) or say there is no limit (in the case of Javier Castellanos' answer).
I've tried removing the process limit like you suggested, with no change in the results.

Offline

#8 2024-11-17 16:51:38

seth
Member
Registered: 2012-09-03
Posts: 58,974

Re: [Solved] Docker kills apt-get

I am running docker from the normal repos, not docker-desktop.I am running docker from the normal repos, not docker-desktop.

'key…

and the crash always happens when installing libpq-dev.

2.598 The following packages will be upgraded:
2.599   libpq-dev libpq5

What if you structure

RUN sleep 30
RUN apt update
RUN apt install -y gcc
RUN sleep 30
RUN apt install -y libpq5
RUN apt install -y libpq-dev

Offline

#9 2024-11-17 17:37:04

JoMaZu787
Member
Registered: 2024-05-29
Posts: 13

Re: [Solved] Docker kills apt-get

docker build app

[+] Building 64.5s (10/14)                                                                                                                       docker:default
 => [internal] load build definition from Dockerfile                                                                                                       0.0s
 => => transferring dockerfile: 284B                                                                                                                       0.0s
 => [internal] load metadata for docker.io/library/python:3.12                                                                                             0.0s
 => [internal] load .dockerignore                                                                                                                          0.0s
 => => transferring context: 2B                                                                                                                            0.0s
 => CACHED [ 1/10] FROM docker.io/library/python:3.12                                                                                                      0.0s
 => [internal] load build context                                                                                                                          0.0s
 => => transferring context: 29B                                                                                                                           0.0s
 => [ 2/10] RUN sleep 30                                                                                                                                  30.3s
 => [ 3/10] RUN apt update                                                                                                                                 2.2s
 => [ 4/10] RUN apt install -y gcc                                                                                                                         0.7s
 => [ 5/10] RUN sleep 30                                                                                                                                  30.4s
 => ERROR [ 6/10] RUN apt install -y libpq5                                                                                                                0.9s
------
 > [ 6/10] RUN apt install -y libpq5:
0.401 
0.401 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
0.401 
0.404 Reading package lists...
0.741 Building dependency tree...
0.815 Reading state information...
0.886 The following additional packages will be installed:
0.886   libpq-dev
0.887 Suggested packages:
0.887   postgresql-doc-15
0.898 The following packages will be upgraded:
0.898   libpq-dev libpq5
0.902 Killed
------
Dockerfile:7
--------------------
   5 |     RUN apt install -y gcc
   6 |     RUN sleep 30
   7 | >>> RUN apt install -y libpq5
   8 |     RUN apt install -y libpq-dev
   9 |     RUN pip install sqlalchemy psycopg2 nicegui
--------------------
ERROR: failed to solve: process "/bin/sh -c apt install -y libpq5" did not complete successfully: exit code: 137

same issue, but with the libpq5 command

Offline

#10 2024-11-17 20:30:30

seth
Member
Registered: 2012-09-03
Posts: 58,974

Re: [Solved] Docker kills apt-get

It's probably been libpq5 all along?
If you remove the sleeps, does the failure move into libpq-dev?

Can you install postgresql-doc-15 ?

Offline

#11 2024-11-18 20:43:08

JoMaZu787
Member
Registered: 2024-05-29
Posts: 13

Re: [Solved] Docker kills apt-get

If you remove the sleeps, does the failure move into libpq-dev?

No, but I've noticed that libpq-dev and libpq5 depend on each other, so I don't think it's possible to separate which one is causing the issue.

Can you install postgresql-doc-15 ?

I tried but...

docker build app

[+] Building 1.1s (8/13)                                                                                                                                                                                                                                                                          docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                        0.0s
 => => transferring dockerfile: 295B                                                                                                                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/python:3.12                                                                                                                                                                                                                                              0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                                             0.0s
 => [internal] load build context                                                                                                                                                                                                                                                                           0.0s
 => => transferring context: 29B                                                                                                                                                                                                                                                                            0.0s
 => [1/9] FROM docker.io/library/python:3.12                                                                                                                                                                                                                                                                0.0s
 => CACHED [2/9] RUN apt update                                                                                                                                                                                                                                                                             0.0s
 => CACHED [3/9] RUN apt install -y gcc                                                                                                                                                                                                                                                                     0.0s
 => ERROR [4/9] RUN apt install -y postgresql-doc-15                                                                                                                                                                                                                                                        1.1s
------
 > [4/9] RUN apt install -y postgresql-doc-15:
0.278 
0.278 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
0.278 
0.280 Reading package lists...
0.745 Building dependency tree...
0.915 Reading state information...
1.046 The following additional packages will be installed:
1.046   libpq-dev libpq5
1.061 The following NEW packages will be installed:
1.061   postgresql-doc-15
1.061 The following packages will be upgraded:
1.061   libpq-dev libpq5
1.065 Killed
------
Dockerfile:5
--------------------
   3 |     RUN apt update
   4 |     RUN apt install -y gcc
   5 | >>> RUN apt install -y postgresql-doc-15
   6 |     RUN apt install -y libpq5
   7 |     RUN apt install -y libpq-dev
--------------------
ERROR: failed to solve: process "/bin/sh -c apt install -y postgresql-doc-15" did not complete successfully: exit code: 137

...same issue, it pulls in libpq5 and libpq-dev as dependencies. (Looking at the Ubuntu Package Search it looks like postgresql-doc-15 only needs libpq5, but that pulls in libpq-dev because that's just the headers for libpq5)

EDIT: Forgot to clear cache, but it gives the same result with --no-cache

Last edited by JoMaZu787 (2024-11-18 20:45:04)

Offline

#12 2024-11-19 07:34:51

seth
Member
Registered: 2012-09-03
Posts: 58,974

Re: [Solved] Docker kills apt-get

https://packages.debian.org/bookworm/libpq5 doesn't seem to depend on https://packages.debian.org/bookworm/libpq-dev  and https://packages.debian.org/bookworm/postgresql-doc-15 doesn't have any deps at all?

   6 |     RUN apt install -y libpq5
   7 |     RUN apt install -y libpq-dev

You're dragging that in, but though the idea was to check whether you can install "just" postgresql-doc-15 it doesn't seem so.
What if you skip gcc and install just and only libpq5 ?

Edit: hold on

Looking at the Ubuntu Package Search it looks like postgresql-doc-15

No ubuntu release seems to ship -15 at all, how does ubuntu come into this mix?

Last edited by seth (2024-11-19 07:37:08)

Offline

#13 2024-11-19 09:42:35

mithrial
Member
Registered: 2017-03-05
Posts: 51

Re: [Solved] Docker kills apt-get

Did you set up any "security" measurements or docker settings? This looks like the docker daemon kills the container.

Offline

#14 2024-11-19 12:48:49

JoMaZu787
Member
Registered: 2024-05-29
Posts: 13

Re: [Solved] Docker kills apt-get

No ubuntu release seems to ship -15 at all, how does ubuntu come into this mix?

Sorry, got that mixed up, Ubuntu has nothing to do with this

Offline

#15 2024-11-19 13:54:04

seth
Member
Registered: 2012-09-03
Posts: 58,974

Re: [Solved] Docker kills apt-get

seth wrote:

What if you skip gcc and install just and only libpq5 ?

Basically the question is whether you run into some limit at some point.

Offline

#16 2024-11-19 14:37:21

JoMaZu787
Member
Registered: 2024-05-29
Posts: 13

Re: [Solved] Docker kills apt-get

seth wrote:

What if you skip gcc and install just and only libpq5 ?

docker build app --no-cache

[+] Building 2.9s (7/10)                                                                                                                                                                                                                                                                          docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                        0.0s
 => => transferring dockerfile: 206B                                                                                                                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/python:3.12                                                                                                                                                                                                                                              0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                                             0.0s
 => [internal] load build context                                                                                                                                                                                                                                                                           0.0s
 => => transferring context: 29B                                                                                                                                                                                                                                                                            0.0s
 => CACHED [1/6] FROM docker.io/library/python:3.12                                                                                                                                                                                                                                                         0.0s
 => [2/6] RUN apt update                                                                                                                                                                                                                                                                                    2.1s
 => ERROR [3/6] RUN apt install -y libpq5                                                                                                                                                                                                                                                                   0.9s 
------                                                                                                                                                                                                                                                                                                           
 > [3/6] RUN apt install -y libpq5:
0.364 
0.364 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
0.364 
0.365 Reading package lists...
0.697 Building dependency tree...
0.764 Reading state information...
0.829 The following additional packages will be installed:
0.829   libpq-dev
0.830 Suggested packages:
0.830   postgresql-doc-15
0.841 The following packages will be upgraded:
0.841   libpq-dev libpq5
0.844 Killed
------
Dockerfile:4
--------------------
   2 |     
   3 |     RUN apt update
   4 | >>> RUN apt install -y libpq5
   5 |     RUN pip install sqlalchemy psycopg2 nicegui
   6 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c apt install -y libpq5" did not complete successfully: exit code: 137

still the same thing happening

Offline

#17 2024-11-19 15:06:10

cryptearth
Member
Registered: 2024-02-03
Posts: 1,010

Re: [Solved] Docker kills apt-get

this issue seems to be around since 2015
from several issues I read this seems to be a version mismatch
can you please add a

--verbose-versions

to see if libpq5 matches libpq-dev

Offline

#18 2024-11-19 17:48:30

JoMaZu787
Member
Registered: 2024-05-29
Posts: 13

Re: [Solved] Docker kills apt-get

                                                                                                                                                                                                                                                                                                       
 > [3/6] RUN apt install -y libpq5 --verbose-versions:
0.334 
0.334 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
0.334 
0.336 Reading package lists...
0.693 Building dependency tree...
0.774 Reading state information...
0.864 The following additional packages will be installed:
0.865    libpq-dev (15.9-0+deb12u1)
0.866 Suggested packages:
0.866    postgresql-doc-15 (15.9-0+deb12u1)
0.879 The following packages will be upgraded:
0.879    libpq-dev (15.8-0+deb12u1 => 15.9-0+deb12u1)
0.880    libpq5 (15.8-0+deb12u1 => 15.9-0+deb12u1)
0.885 Killed

same version

Offline

#19 2024-11-19 19:35:11

twelveeighty
Member
From: Alberta, Canada
Registered: 2011-09-04
Posts: 1,140

Re: [Solved] Docker kills apt-get

Since you're starting with a "python:3.12" image, you should be wary of what they've "done" to the Debian image. Is there a reason you're not calling "dist-upgrade" after the "update"? I would also recommend pulling a specific O/S tagged version of Python, e.g. "python:3.12-bookworm", or, alternatively, if you're adding a large amount of packages, instead switch to a Debian image and add Python instead of the other way around.

Offline

#20 2024-11-21 15:50:47

JoMaZu787
Member
Registered: 2024-05-29
Posts: 13

Re: [Solved] Docker kills apt-get

Solved the issue by using the psycopg-binary pip module instead of psycopg so that i don't need the libpq debian packages

Offline

Board footer

Powered by FluxBB