我在连接使用vs代码生成的容器中运行的django进程时遇到了问题。一切似乎都正常,我得到了服务器的启动消息,但是当连接到localhost:8000时,我没有得到响应.
启动容器时,我会收到一条已发布的端口消息:
发布的端口: 8000/tcp -> 127.0.0.1:8000
在启动launch.json调试时,也是一个干净的开始。
系统检查没有发现任何问题(0被沉默)。2019年10月13日-17:45:45:05 Django版本2.2.6,使用设置‘fpl django.set’在http://127.0.0.1:8000/启动开发服务器,退出带有CONTROL的服务器。
为什么我不能访问这个网站: localhost:8000?
devcontainer.json:
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "../docker/dev/python/Dockerfile",
// The optional 'runArgs' property can be used to specify additional runtime arguments.
"runArgs": [
// Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-in-docker for details.
// "-v","/var/run/docker.sock:/var/run/docker.sock",
// Uncomment the next line if you will be using a ptrace-based debugger like C++, Go, and Rust.
// "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"
// You may want to add a non-root user to your Dockerfile. On Linux, this will prevent
// new files getting created as root. See https://aka.ms/vscode-remote/containers/non-root-user
// for the needed Dockerfile updates and then uncomment the next line.
// "-u", "vscode"
"--network",
"fpl-django_default"
],
// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.linting.pylintEnabled": true,
"python.linting.pylintPath": "/usr/local/bin/pylint",
"python.linting.enabled": true
},
// Uncomment the next line if you want to publish any ports.
"appPort": [
8000
],
// Uncomment the next line to run commands after the container is created - for example installing git.
// "postCreateCommand": "apt-get update && apt-get install -y git",
// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"ms-python.python",
]
}launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"console": "integratedTerminal",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"django": true
}
]
}发布于 2019-10-19 16:19:41
尝试使用这个param:0.0.0.0:8000运行manage.py runserver,这将告诉您的应用程序侦听来自任何主机的请求。就像这样:
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"console": "integratedTerminal",
"args": [
"runserver",
"0.0.0.0:8000",
"--noreload",
"--nothreading"
],
"django": true
}https://stackoverflow.com/questions/58366220
复制相似问题