I had a similar error message ("Cannot find container to attach, check if the container is running or not").
In my case I upgraded my project from net6 to net8 and after that the error occurred.
What didn't help:
- restarting Docker
- removing all (old) project related containers and images
- removing the .vs folder
What did help:
- recreating the Dockerfile (by deleting the old one and adding Docker support again). In the Dockerfile there is also a reference to framework version so that might be the reason that it didn't work in the first place.