bash: ifconfig: command not found in an Ubuntu container means the net-tools package is not installed. Run apt-get update and apt-get install -y net-tools, or use ip addr from iproute2 instead.

Both commands were missing in the tested images, so either way you install one package. net-tools is the package that provides ifconfig.

The error

docker exec fix10-lc-r1 bash -ic 'ifconfig 2>&1'
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
bash: ifconfig: command not found

The first two lines come from starting an interactive shell without a terminal. A container from mcr.microsoft.com/dotnet/aspnet:10.0 printed the same bash: ifconfig: command not found.

Why it happens

ifconfig belongs to the net-tools package, which the ubuntu:24.04 and ASP.NET Core runtime images tested here do not include. Bash searched the PATH, found no such program and printed the message. The container's network was not the problem: after the install, the same container showed its loopback interface with traffic counters.

A fresh container also has no package lists, so apt-get install on its own stops with E: Unable to locate package; run apt-get update first.

The fix

docker exec fix10-lc-r1 bash -ic 'apt-get update > /dev/null; echo update-exit=$? 2>&1'
...
update-exit=0
...
docker exec fix10-lc-r1 bash -ic 'apt-get install -y net-tools > /dev/null; echo install-exit=$? 2>&1'
...
debconf: delaying package configuration, since apt-utils is not installed
install-exit=0

docker exec fix10-lc-r1 bash -ic 'ifconfig lo 2>&1'
...
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 4  bytes 336 (336.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 336 (336.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

The debconf line is a notice; the install returned 0. The alternative is the iproute2 package, whose ip -brief addr printed one line per interface in the same container. An install made with docker exec did not survive the container in a test with ping (a new container from the same image lacked the command), while an image built with the update and install in one Dockerfile RUN line had it; do the same with net-tools.

To check in a script whether the tools are there before you call them, use command -v. In a fresh container it printed nothing and returned 1; after the installs it printed every path and returned 0:

docker exec fix10-lc-r1 bash -c 'command -v ping ip ifconfig sudo; echo exit=$?'
/usr/bin/ping
/usr/sbin/ip
/usr/sbin/ifconfig
/usr/bin/sudo
exit=0

Note that ifconfig and ip land in /usr/sbin, while ping and sudo are in /usr/bin; as root in the container the plain names worked for all four.

How it was reproduced

The captures were made in containers created from ubuntu:24.04 (Ubuntu 24.04.5 LTS, bash 5.2.21, apt 2.8.3) and mcr.microsoft.com/dotnet/aspnet:10.0 with docker run -d --name ... sleep infinity on Docker Engine 29.9.3, and the commands were sent with docker exec. The installed package was net-tools 2.10-0.1ubuntu4.4. The fix10-lc- container names are the test's own. Every command was sent from Windows PowerShell 5.1 exactly as shown, with the -c text in single quotes so it reached the container unchanged; a single quote inside that text is written twice, as PowerShell requires.

Frequently asked

Which package provides ifconfig on Ubuntu?
net-tools. In the test apt-get install -y net-tools returned 0 and ifconfig lo then printed the loopback interface.
Why is ifconfig not found in a Docker container?
The ubuntu:24.04 and aspnet:10.0 images tested here do not include net-tools, so bash finds no ifconfig on the PATH.
What can I use instead of ifconfig?
ip from the iproute2 package. In the same container ip -brief addr listed lo and eth0 with their addresses.

More decoded errors in the Fixes category. For the modern command see bash: ip: command not found.