Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can we fix some file inside a failed-to-start docker container?

I have a container which fails to start.

Error response from daemon: failed to create shim task: OCI runtime create failed: 
  runc create failed: unable to start container process: 
    exec: "/scripts/run_task.sh": permission denied: unknown

If I inspect the container, I can see

[
    {
        "Id": "6ea7961f70fac969d6e91bde125ff64f79f856171e17827a9a6ded19fe6629a2",
        "Created": "2023-03-30T07:12:37.342296803Z",
        "Path": "/scripts/run_task.sh",
        "Args": [],
        "State": {
            "Status": "created",
            "Running": false,
            "ExitCode": 126,
            "Error": "failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: \"/scripts/run_task.sh\": permission denied: unknown",
            ...
        },
        ...
        "Config": {
            ... ,
            "Env": [
                "APP_ENV=local_task",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin",
                "LANG=ja_JP.utf8"
            ],
            "Cmd": null,
        
            "Entrypoint": [
                "/scripts/run_task.sh"
            ],
            "OnBuild": null,
        }
    }
]

Maybe it is simply caused by wrong file mode of ‘/scripts/run_task.sh‘,
but the container is not running, I can not do something like ‘docker exec -it xxx bash‘,
do we have some way to inspect/fix some file inside a failed-to-start docker container?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks.

>Solution :

If the image fails to run when you start it, then the right thing to do is to find out what is wrong and build a new image that can run.

Trying to make current image run without modifying it will at best be a work-around and will be annoying to have to do every time you want to run the image.

To help you in diagnosing the problem, you can override the entrypoint when you run the image. Then you can start a shell in the container and look at the permissions on your run_task.sh file.

To do that, you can run the image like this

docker run -it --entrypoint /bin/sh <image name>

That should put you in a shell inside the container and you can explore the file system.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading