Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "python":

I keep getting this error in a Docker container when I execute docker run.

Dockerfile

FROM python:3.9.7-slim-bullseye
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
RUN apt-get install libpcre2-8-0
RUN ldconfig
COPY requirements.txt /code/
RUN pip
RUN pip install -r requirements.txt
COPY . /code/
EXPOSE 80
CMD ["python", "manage.py", "makemigrations"]
CMD ["python", "manage.py", "migrate"]
#CMD ["daphne", "-b", "0.0.0.0", "-p", "80", "testyou.asgi:application"]
CMD ["python", "manage.py", "runserver" ,"0.0.0.0:80"]

Docker process

docker ps -a
CONTAINER ID   IMAGE      COMMAND                  CREATED         STATUS    PORTS                                   NAMES
b3a34c8e8836   new_stra   "python manage.py ru…"   2 minutes ago   Created   0.0.0.0:8000->80/tcp, :::8000->80/tcp   jolly_feis

Error

sudo docker run -it -d --mount type=bind,source=/tmp,target=/usr --network ava-net -p 8000:80 --add-host=host.docker.internal:host-gateway new_stra
b3a34c8e8836a0671ad32b919503b423cac5d8326a9d3e7b04fb427a2f69311b
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "python": executable file not found in $PATH: unknowny

docker logs

b3a34c8e8836
<no output>

docker inspect 59a03e87fe83

[
    {
        "Id": "59a03e87fe8331c7e905fe52a059f4642ebfbb84dfd32bfa1605ee410787a375",
        "Created": "2021-09-19T01:13:45.268441245Z",
        "Path": "bash",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 18364,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2021-09-19T01:13:45.822296196Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:b9cda896590a06a5affbd238a52cc601d3b1ae84bbcd18fa0f965847cb71beed",
        "ResolvConfPath": "/var/lib/docker/containers/59a03e87fe8331c7e905fe52a059f4642ebfbb84dfd32bfa1605ee410787a375/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/59a03e87fe8331c7e905fe52a059f4642ebfbb84dfd32bfa1605ee410787a375/hostname",
        "HostsPath": "/var/lib/docker/containers/59a03e87fe8331c7e905fe52a059f4642ebfbb84dfd32bfa1605ee410787a375/hosts",
        "LogPath": "/var/lib/docker/containers/59a03e87fe8331c7e905fe52a059f4642ebfbb84dfd32bfa1605ee410787a375/59a03e87fe8331c7e905fe52a059f4642ebfbb84dfd32bfa1605ee410787a375-json.log",
        "Name": "/nervous_fermat",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "ava-net",
            "PortBindings": {
                "80/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "8000"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": [
                "host.docker.internal:host-gateway"
            ],
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "Mounts": [
                {
                    "Type": "bind",
                    "Source": "/tmp",
                    "Target": "/usr"
                }
            ],
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/07f638374e100bcfae43a6650f2951923c91a4c2e34f1cfe25d6cc2171363c21-init/diff:/var/lib/docker/overlay2/f86ea7a4b5e25edbb61a73fc1b8490dfa62d49fd9b07fc23e417ac935e9c3909/diff:/var/lib/docker/overlay2/0f165decf69ef3a140f4e974bdbb22a92b5449c1ae07427a115a08c630096e9d/diff:/var/lib/docker/overlay2/9bad450a362c7dd468a4a3cd8cb02a00c8d28f471d7fb08740f68b83f7bee677/diff:/var/lib/docker/overlay2/ebed308745e38f13323e5f97645eb1065b3586261dd6c33e65c836c3e65f85bd/diff:/var/lib/docker/overlay2/239e4c65ef04a85394068951d01593f9e3ae67ad47dccd617d0dcdef6ced4d53/diff:/var/lib/docker/overlay2/ca0b1bb31289eb67352854d22d534be574768a659f341ed5341d47eff9e88ae4/diff:/var/lib/docker/overlay2/ed41a88395d494bd0ead951e5b4fa85e6815d572f94b24749f1b020308c29547/diff:/var/lib/docker/overlay2/acec57d4ea8ea8502dbb71db43a83abd97c65a7d6a3b0351970cfef7e45e86d0/diff:/var/lib/docker/overlay2/3c2efb4042dd22c139dc8e8bae130de8737d8db99f18685ec376bca59d994f86/diff:/var/lib/docker/overlay2/c7cf000c42a47504a8be1142b88548497d157232daff1fb94aea6be2d4206156/diff:/var/lib/docker/overlay2/8ed98ca75735676fb7bd03ba1f5fad9fe1b5c432b825e16cd41814bbcf519ee5/diff:/var/lib/docker/overlay2/5e3558c34cec38c811563e196bd022f424695a6c34d517e636b5cd1458209da4/diff",
                "MergedDir": "/var/lib/docker/overlay2/07f638374e100bcfae43a6650f2951923c91a4c2e34f1cfe25d6cc2171363c21/merged",
                "UpperDir": "/var/lib/docker/overlay2/07f638374e100bcfae43a6650f2951923c91a4c2e34f1cfe25d6cc2171363c21/diff",
                "WorkDir": "/var/lib/docker/overlay2/07f638374e100bcfae43a6650f2951923c91a4c2e34f1cfe25d6cc2171363c21/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/tmp",
                "Destination": "/usr",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "59a03e87fe83",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "LANG=C.UTF-8",
                "GPG_KEY=E3FF2839C048B25C084DEBE9B26995E310250568",
                "PYTHON_VERSION=3.9.7",
                "PYTHON_PIP_VERSION=21.2.4",
                "PYTHON_SETUPTOOLS_VERSION=57.5.0",
                "PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/c20b0cfd643cd4a19246ccf204e2997af70f6b21/public/get-pip.py",
                "PYTHON_GET_PIP_SHA256=fa6f3fb93cce234cd4e8dd2beb54a51ab9c247653b52855a48dd44e6b21ff28b",
                "PYTHONUNBUFFERED=1"
            ],
            "Cmd": [
                "bash"
            ],
            "Image": "new_stra",
            "Volumes": null,
            "WorkingDir": "/code",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "a029a65cc3925ffe0b85794b98d846e0e2d3b54023bebfe0451c22ed65507f6a",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "80/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "8000"
                    },
                    {
                        "HostIp": "::",
                        "HostPort": "8000"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/a029a65cc392",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "ava-net": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "59a03e87fe83"
                    ],
                    "NetworkID": "3fcc7b14d8b8090280303e7cfa4533c985f044ecf505dea424e6ef7af394f2c5",
                    "EndpointID": "b6e9db6a63498a440abdf67e761f3e2b3e0224a34e0fb4819c91e7ea183410d7",
                    "Gateway": "172.18.0.1",
                    "IPAddress": "172.18.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:12:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]

It looks like the bind mount was the issue. I was mounting to /bin/usr, which was somehow causing the error.

I have almost the same problem as you, except that it is not “python” but “–v=2”. How did you solve this problem please?

This is one of the most common issue that beginners have. Please, everyone, try to understand the cause and don’t focus on strange “starting container process: exec” part of the message but the less confusing “executable file not found in $PATH”.

But if you search for the confusing part on the internet you will find lots of example for what it means. Your command inside the container is wrong. The command in the simplest case is an executable unless you have an entrypoint defined which uses the command as a parameter.

If you delete the entrypoint definition the parameter itself will not be executable.

Make sure the ENTRYPOINT and a CMD (in some cases also the SHELL) directives are right.

In my case, instead of
executable file not found in $PATH: unknowny
I got permission denied.

I had to add execute permission to my local executable file which was getting copied to docker container and was the entrypoint. Silly that docker didn’t tell me the file name of permission denied file.

I think Docker usually warns you about permission issues related to the entrypoint.

bash-5.1$ docker run --rm -it -v $PWD/test.sh:/test.sh bash /test.sh
/usr/local/bin/docker-entrypoint.sh: line 11: /test.sh: Permission denied
bash-5.1$ docker run --rm -it --entrypoint /test.sh -v $PWD/test.sh:/test.sh bash
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/test.sh": permission denied: unknown.
bash-5.1$ docker run --rm -it --entrypoint test.sh -v $PWD/test.sh:/test.sh bash
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "test.sh": executable file not found in $PATH: unknown.

If it doesn’t warn you then Docker probably was not able to detect the issue and the root of the problem is somewhere else. Since this topic is about “starting container process caused: exec …”, if you still would like to have an answer to your case, I suggest you create a new topic with your error message in the title and we can try to find the reason why you didn’t get a proper error message.

I had a very simple mistake having a similar PATH error:

I have put --network after the container tag:

docker run --net SUBNET1 nodetag1:0 --hostname node1 -p 8888:8888/tcp
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "--hostname": executable file not found in $PATH: unknown.

The following works excellent:

docker run --net subnet1 --hostname node1 -p 8888:8888/tcp nodetag1:0

I got the same error too. I had a problem because I used the commands in the wrong syntax.

Wrong syntax:

docker container run -d -p 80:80 --name websunucu1 ozgurozturknet/adanzyedocker -v C:\deneme:/usr/local/apache2/htdocs

Correct syntax:

docker container run -d --name websunucu1 -p 80:80 -v C:\deneme:/usr/local/apache2/htdocs ozgurozturknet/adanzyedocker

The last two responses show problems caused by not using the right syntax (in both cases [OPTIONS] have been used after IMAGE, which caused them to be the COMMAND and ARGS to the entrypoint script) and solutions by using the right syntax.

Note: These posts are actually off-topic and not related to the problem of the OP.

sudo docker run --tty --network postgres_debezium_cdc_default confluentinc/cp-kafkacat \ 
kafkacat -b kafka:9092 -C -s key=s -s value=avro -r \
http://schema-registry:8081 -t postgres.public.students

while I am running this command from my linux terminal, getting below error,

docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: " ": executable file not found in $PATH: unknown.
ERRO[0001] error waiting for container:                 
% ERROR: This build of kafkacat lacks Avro/Schema-Registry support

Looking for support.

It looks like you have a space after the backslash after the image name. That way you actually pass the space as an argument which is not a command of course. Remove the space after the backslash or remove the backslash and it should work.

Also please don’t quote code, use the code block button right next to the quote button: (</>)
I fixed it for you this time.

A post was split to a new topic: Cannot access entrypoint.sh: No such file or directory