Here is how you should install Docker
You have an older Docker version installed from Ubuntu’s repository and Docker Compose is v1 which is deprecated deprecated and will not be supported after the end of June.
Does internet connection work when you just run a container instead of building an image? Please check the other topic where you posted first and try my suggestions like this one
It is not likely that I will have more ideas unless you can show me something that I haven’t seen before and haven’t suggested a test or solution to.