Package 'netcat' has no installation candidate. How to fix this?

I’m using Docker Desktop 4.20.1 on Windows 11 using WSL2
This is my first time using Docker.
In Powershell at the root of my project I run

docker-compose up -d --build

The output is this:

> [api 2/6] RUN set -e;     apt-get update ;    apt-get -y install netcat ;    apt-get -y install gettext ;:
#0 0.856 Get:1 bookworm InRelease [147 kB]
#0 0.969 Get:2 bookworm-updates InRelease [52.1 kB]
#0 1.058 Get:3 bookworm-security InRelease [48.0 kB]
#0 1.152 Get:4 bookworm/main amd64 Packages [8904 kB]
#0 2.043 Get:5 bookworm-security/main amd64 Packages [30.4 kB]
#0 3.215 Fetched 9182 kB in 3s (3523 kB/s)
#0 3.215 Reading package lists...
#0 3.801 Reading package lists...
#0 4.344 Building dependency tree...
#0 4.494 Reading state information...
#0 4.501 Package netcat is a virtual package provided by:
#0 4.501   netcat-openbsd 1.219-1
#0 4.501   netcat-traditional 1.10-47
#0 4.501
#0 4.505 E: Package 'netcat' has no installation candidate
failed to solve: process "/bin/sh -c set -e;     apt-get update ;    apt-get -y install netcat ;    apt-get -y install gettext ;    apt-get -y  install httpie;     pip install --upgrade pip     pip install flask" did not complete successfully: exit code: 100

I’ve tried reinstalling Docker Desktop. I also know about trying apt --update then apt --install netcat However, I don’t know where I should do these commands. There isn’t a terminal available in the Docker application yet.

1 Like

This isn’t a Docker-specific issue, however, the warning

Package netcat is a virtual package provided by:
    netcat-openbsd 1.219-1
    netcat-traditional 1.10-47

is the root of your issue. On Debian, netcat isn’t a package, as two “variations” of netcat exist in the package repository. Instead, replace the apt install netcat with apt install netcat-traditional and it will be installed.

1 Like

Thank you for clarifying the error message.
Your solution worked!
I had tried changing it to netcat-traditional in the Dockerfile earlier today with no luck. I didn’t realize it needed to be changed in Dockerfile_app as well.
Thanks for the response. My apologies for the noob question.

Thanks for the tip the following did work ! :grinning:

apt install netcat-traditional
1 Like

where to use this command?
i was using docker-compose up -d --build in my vs code terminal and it gave me that error