I just wanted to add this hint to get a default devcontainer working with local domains.
I have used Traefik as a reverse proxy to automatically generate LetsEncrypt certs. Now I use OrbStack (on a Mac) which automatically creates a local domain for you.
However, neither options works with a default generated devcontainer. The problem is that the server does not automatically start. Both Traefik and OrbStack immediately try to connect to the container to create the connection. When you run “bin/dev” after it is too late for them to pick up the server and it can’t properly configure the local domain to forward to the server.
As a fix I added the following to devcontainer.json:
// Use 'postStartCommand' to run commands after the container is started.
"postStartCommand": "bin/dev"
This will start the development processes automatically after creating and setting up the containers. Both Traefik reverse proxy and OrbStack sucessfully connect the local domain to the server.
If anyone has a better way to make this happen please let me know. I am not a devcontainer expert.