Skip to content
Advertisement

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
                }
            }
        }
    }
]

Advertisement

Answer

your python binary resides in /usr/local/bin and with your mount you override it with whatever is in /tmp path on your host

>docker run -it python:3.9.7-slim-bullseye /bin/bash
root@8c92c001fdaf:/# which python
/usr/local/bin/python
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement