I have got a similar setup on host machine and it works flawlessly.
However, I have setup docker to work in VSC dev containers. The problem arises when I connect to container through VSC. I’ve discovered that VSC uses some ports like 5760, 5860, … etc, therefore default simulation port is blocked and the whole setup does not work.
Thank you, czuczo
Shortly after posting this question I have discovered why VS Code uses these ports.
This is due to automatic port forwarding. Each time sim_vehicle.py is called, VS Code in dev container recognizes that there is some service on localhost:5760 and forwards this port. Then it gets blocked immediately and whole SITL setup doesn’t work. The port forwarding persists even when you end the session and come back later.
To solve this issue one can turn off automatic port forwarding by adding the code below to devcontainer.json.