Cannot run docker image after export-import activity

Viewed 32

I had an image which I ran and then commited changes. I didn't need all previous ones so I decided somehow "prune" them. I found a guide in the Internet which told that you should export top image and then import it again.

I followed this plan and tried to run my imported image. Unfortunately, the imported image doesn't have CMD set and have no command to start with. Again, I surfed the Internet and found that I have to build a new image from the imported one with CMD set to executable (`/bin/bash' for instance).

Here's a Dockerfile:

FROM imported_image
CMD ["/bin/bash"]

Build runs well:

user@host:~$ docker build -t test .
Sending build context to Docker daemon  332.6MB
Step 1/2 : FROM imported_image
 ---> e06778aa0d79
Step 2/2 : CMD ["/bin/bash"]
 ---> Running in 86bab37ca0a7
Removing intermediate container 86bab37ca0a7
 ---> af690b368da5
Successfully built af690b368da5
Successfully tagged test:latest

But when I run this new image I bump into the same error:

user@host:~$ docker run -p 1521:1521 --rm -it test:latest /bin/bash
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown.

Here's an output of docker inspect of imported image:

....
        "ContainerConfig": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": null,
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
....

And here's an output for test image:

....
        "ContainerConfig": {
            "Hostname": "86bab37ca0a7",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "CMD [\"/bin/bash\"]"
            ],
            "Image": "sha256:e06778aa0d792a0595a7e4bbfa6d719bb9a44b23fac49bbc7cfec625f88be92a",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
....

The imported image was built from oracle/linux one. I've googled and found that /bin/bash must be there. I expect at least to run the image with provided absolute path to executable but it doesn't work:

user@host:~$ docker run -p 1521:1521 --rm -it imported_image /bin/bash
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown.

So am I missing something? And can this imported image be recovered? Can I somehow "look" into the image filesystem to find a sh or bash location?

UPD: Running using sh doesn't work either:

user@host:~$ docker run -p 1521:1521 --rm -it test:latest sh
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "sh": executable file not found in $PATH: unknown.
user@host:~$ docker run -p 1521:1521 --rm -it test:latest /bin/sh
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/bin/sh": stat /bin/sh: no such file or directory: unknown.

UPD2: Interesting that providing the exact user causes error:

user@host:~$ docker run -p 1521:1521 --rm -it --user=oracle test:latest sh
docker: Error response from daemon: unable to find user oracle: no matching entries in passwd file.
user@host:~$ docker run -p 1521:1521 --rm -it --user=root test:latest sh
docker: Error response from daemon: unable to find user root: no matching entries in passwd file.

Looks like the problem lays deeper.

1 Answers

Your imported_ Image what is the Linux version of Ubuntu CentOS or apline? You can try using sh instead of bash

Related