Debugging Django with VS Code inside a Docker container shuts down the container

  django, docker, visual-studio-code

I’m following this guide for debugging Django inside a Docker container using VS Code. The only difference I’ve made was changing ports to 8000 and host to 0.0.0.0 because my docker-compose has it like that.
I have no idea why the web container shuts down when I run Django with a breakpoint inside a view because I’m don’t really know where the problem is coming from. My only guess is from the vscode/launch.json file that is set up by the following:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Run Django",
      "type": "python",
      "request": "attach",
      "pathMappings": [
        {
          "localRoot": "${workspaceFolder}/app",
          "remoteRoot": "/usr/src/app"
        }
      ],
      "port": 8000,
      "host": "0.0.0.0",
    }
  ]
} 

Any ideas why this is not working or where the problem is coming from?

Source: Docker Questions

LEAVE A COMMENT