Same image refuses to run on Ubuntu 21, but runs on Ubuntu 20. Docker versions are the same

(partially solved, see UPDATE1, import/export issue)

I recently pulled an image from docker hub, named amd64/ubuntu:latest. I modified it slightly on my Desktop machine, which is Ubuntu 20.04. The image I downloaded is also and image of Ubuntu 20.04, as I could verify by checking the /etc/lsb-release file inside the container.

The modifications were minor: I installed zsh, compiled vim and compiled sshd (because installing packages for those two takes much more space). Everything worked inside the container. I then created another image from that modified container, removed the container and started a new one from the modified image with this command:

$ docker run -dit --name=myubuntu20 local/ubuntu:March07_2022

This would work with no problem, and I would then start sshd daemon on it (while not common to call sshd this way, it does work):

$ docker exec myubuntu20 bash -c 'service ssh start'

I made /etc/init.d/ssh in the container as simple as possible only containing these two lines:

#!/bin/sh
/usr/local/sbin/sshd

So everything worked and I was able to connect normally via ssh.

THEN I decide to test this image on another machine, namely Ubuntu 21 VirtualBox installation. I save the image as a .tgz archive and import it inside the Ubuntu 21 Machine - exactly as per Docker documentation, naming it the same as the image on my Desktop machine. Attempts to run the image on Ubuntu 21 failed though. Here’s what I tried on Ubuntu 21 Virtual Box (all of these work on Ubuntu 20 Desktop):

$ docker run -dit --name=myubuntu20 local/ubuntu:March07_2022
docker: Error response from daemon: No command specified.
# RESULT: container is not created at all.

Fine, I read the docs, let’s try adding something as a command:

$ docker run -dit --name=myubuntu20 local/ubuntu:March07_2022 /bin/sh -c 'echo hello'

86cca2e49ee136c52145788f8883af159d53e99ea5ce52e3fc58469a6310121d
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.

This time, a container had been created, but not started. I tried different commands apart form /bin/sh and I double checked - it does exist inside the container, so the file is there. I tried /usr/bin/bash, /usr/bin/sh, even /usr/local/sbin/sshd - all with the same result as above.

At present time, I find it not likely that this is due to VirtualBox, but perhaps I am being wrong. I’m currently installing Ubuntu 20 on it to try and run it there and will also try running on another hardware and not inside a Virtual machine. However, it does seem very strange this should even happen.

Docker versions are exactly the same on both machines:

$ /usr/bin/dockerd --version
Docker version 20.10.12, build 459d0df
$ docker --version
Docker version 20.10.12, build e91ed57

They also seem to be running with the same configuration parameters, as I haven’t changed much, so the output is THE SAME for both machines:

$ ps aux | grep '[d]ocker'
root /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

(process ids and other irrelevant info is stripped)

Could anyone please give me a hint at what’s going it? Perhaps saving and/or importing images is broken?

UPDATE 1 (partially solved)
Yes, it appears to be an export/import issue, because when I simply uploaded the image to Docker Hub and pulled it on another machine - it worked. Still remains the question, why is the export/import broken? Should repo name be exactly the same upon import or is there something else? Again, the commands used were all as per documentation:

$ docker image save local/ubuntu:March07_2022 -o ubuntu.tgz # on Ubuntu 20
$ docker import ubuntu.tgz local/ubuntu:March07_2022 # on Ubuntu 21

You should use docker image load -i ubuntu.tgz instead of docker import. Import is just to import a “filesystem image” without metadata like “CMD”.