Привет, я хочу отладить django на удаленном docker сервере. Вот моя попытка:
version: '3'
services:
db:
image: postgres
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
web:
build: .
command: python manage.py runserver --noreload 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
- "9000:9000"
environment:
- DJANGO_DEBUG=1
depends_on:
- db
Dockerfile
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
# COPY . /code/
manage.py
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Remote Django App",
"type": "python",
"request": "attach",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/code"
}
],
"port": 9000,
"host": "192.168.1.15"
}
]
}
Запустить. json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Remote Django App",
"type": "python",
"request": "attach",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/code"
}
],
"port": 9000,
"host": "192.168.1.15"
}
]
}
Ожидаемый : попадание в точку останова.
Фактически произошло : ETIMEDOUT 192.168.1.15 9000
Я действительно могу lnet 192.168.1.15 9000
с результатом:
Content-Length: 130
{"type": "event", "seq": 0, "event": "output", "body": {"category": "telemetry", "output": "ptvsd", "data": {"version": "4.3.2"}}}
Если я посетил 192.168.1.15:9000
с браузером, я получил
web_1 | Exception in thread ptvsd.Server:
web_1 | Traceback (most recent call last):
web_1 | File "/code/ptvsd/ipcjson.py", line 269, in process_one_message
web_1 | msg = self.__message.pop(0)
web_1 | IndexError: pop from empty list
web_1 |
web_1 | During handling of the above exception, another exception occurred:
web_1 |
web_1 | Traceback (most recent call last):
web_1 | File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
web_1 | self.run()
web_1 | File "/usr/local/lib/python3.8/threading.py", line 870, in run
web_1 | self._target(*self._args, **self._kwargs)
web_1 | File "/code/ptvsd/wrapper.py", line 521, in process_messages
web_1 | self.process_messages()
web_1 | File "/code/ptvsd/ipcjson.py", line 258, in process_messages
web_1 | self.process_one_message()
web_1 | File "/code/ptvsd/ipcjson.py", line 272, in process_one_message
web_1 | self._wait_for_message()
web_1 | File "/code/ptvsd/ipcjson.py", line 160, in _wait_for_message
web_1 | raise InvalidHeaderError(
web_1 | ptvsd.ipcjson.InvalidHeaderError: Malformed header, expected 'name: value'
Я не в курсе. Я пробовал разные версии ptvsd без удачи. Я провел часы Google безрезультатно