bash: line 1: systemctl: command not found in an Ubuntu container means the image has no systemd, and installing it does not help: the container's first process is your own command, not systemd. Start the program directly in the foreground instead, or look at the service command the image already has (starting a program either way was not tested here).

In the test, installing the systemd package replaced this message with a different one, System has not been booted with systemd as init system, so the install only moves the problem.

The error

docker exec fix10-lc-r6 bash -c 'systemctl status 2>&1; echo exit=$?'
bash: line 1: systemctl: command not found
exit=127

The command went through bash -c, which is why the message carries line 1:.

Why it happens

The ubuntu:24.04 image does not include the systemd package, so bash finds no systemctl. More important is what runs as process 1 in the container. It was the command given to docker run, here sleep infinity:

docker exec fix10-lc-r6 bash -c 'cat /proc/1/cmdline | tr ''\0'' '' ''; echo; ps -o pid,cmd -p 1 2>&1'
sleep infinity
    PID CMD
      1 sleep infinity

After apt-get install -y systemd the program existed, and its own message named process 1 as the reason it refused:

docker exec fix10-lc-r6 bash -c 'apt-get install -y systemd > /dev/null 2>&1; echo install-exit=$?; systemctl status 2>&1; echo exit=$?'
install-exit=0
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
exit=1

That second message, and the Failed to connect to bus line with it, has its own post.

The fix

What the container has instead is the service command. Asked for the status of everything, it listed one entry, procps, as stopped:

docker exec fix10-lc-r6 bash -c 'command -v service; service --status-all 2>&1; echo exit=$?'
/usr/sbin/service
 [ - ]  procps
exit=0

A package that ships such a script can be started with service <name> start. For anything else, start the program itself: in a Dockerfile make it the CMD, so it is process 1, or run it with docker exec while the container is up. That is the container way to run a service; one container per service, started by Docker rather than by systemd. I did not start a real service in this test, so treat those last lines as the pattern to follow, not a capture.

How it was reproduced

The capture was made in a container started with docker run -d --name fix10-lc-r6 ubuntu:24.04 sleep infinity (Ubuntu 24.04.5 LTS, bash 5.2.21) on Docker Engine 29.9.3, with commands sent through docker exec ... bash -c. The systemd package was installed from the Ubuntu archive with apt-get install -y systemd. The container name is 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

Why is systemctl not found in my Docker container?
The ubuntu:24.04 image has no systemd package. Process 1 in the test container was sleep infinity, the command given to docker run.
Does installing systemd in a container fix systemctl?
No. In the test systemctl then printed System has not been booted with systemd as init system (PID 1) and Failed to connect to bus, with exit code 1.
What can I use instead of systemctl in a container?
The service command was present; service --status-all listed one entry, [ - ] procps. Starting a program directly, for example as the container's CMD, was not tested here.

More decoded errors in the Fixes category.