My docker only works with loopback ip and not with the host IP

Is it still Docker Desktop running in a virtual machine or you installed Docker CE?

If you installed Docker CE, how? Please share the output of the following commands

docker info
docker version
dpkg -l | grep docker
snap list docker

UPDATE:

I almost forgot to note that I edited your post. Please, use code blocks next time. You can find our formatting guide here: How to format your forum posts