Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flask project debug in docker container doesn't start #2716

Closed
m-toman opened this issue Feb 10, 2021 · 14 comments
Closed

Flask project debug in docker container doesn't start #2716

m-toman opened this issue Feb 10, 2021 · 14 comments

Comments

@m-toman
Copy link

m-toman commented Feb 10, 2021

/Hi,

I've encountered the same issue as in #2313 and was not able to resolve it yet.
I am also on Linux but running a Flask app in a docker container.

Followed along https://code.visualstudio.com/docs/containers/debug-python#_for-flask-apps and ended up with:

launch.json

{
    "configurations": [
        {
            "name": "Docker: Python - Flask",
            "type": "docker",
            "request": "launch",
            "preLaunchTask": "docker-run: debug",
            "python": {
                "pathMappings": [
                    {
                        "localRoot": "${workspaceFolder}",
                        "remoteRoot": "/app"
                    }
                ],
                "projectType": "flask"
            }
        }
    ]
}

tasks.json

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "docker-build",
			"label": "docker-build",
			"platform": "python",
			"dockerBuild": {
				"tag": "gisapi:latest",
				"dockerfile": "${workspaceFolder}/Dev.Dockerfile",
				"context": "${workspaceFolder}",
				"pull": true
			}
		},
		{
			"type": "docker-run",
			"label": "docker-run: debug",
			"dependsOn": [
				"docker-build"
			],
			"dockerRun": {
				"env": {
					"FLASK_APP": "gisapi/__init__.py",
					"FLASK_ENV": "development"
				},
				"volumes": [
					{
						"containerPath": "/app",
						"localPath": "${workspaceFolder}"
					}
				],
				"ports": [
					{
						"containerPort": 8090,
						"hostPort": 8090,
						"protocol": "tcp"
					}
				]
			},
			"python": {
				"args": [
					"run",
					"--host",
					"0.0.0.0",
					"--port",
					"8090"
				],
				"module": "flask"
			}
		}
	]
}

When I run the container with F5 it just seems it just runs the "dummy" python interpreter but not actually the flask app.

If I exec -it /bin/bash into the container and run "python -m flask run --host 0.0.0.0 --port 8090" I can connect to the service and it works fine (of course without debugging).

Outputs:

Output: empty

Debug console: empty

Terminal 1: empty

Terminal 2:

> Executing task: docker-run: debug <

> docker run -dt -P --name "gisapi-dev" -e "FLASK_APP=gisapi/__init__.py" -e "FLASK_ENV=development"  --label "com.microsoft.created-by=visual-studio-code" -v "/home/mtoman/geoserver/gisapi:/app" -v "/home/mtoman/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/lib/python/debugpy:/debugpy:ro" -p "8090:8090/tcp" --entrypoint "python" "gisapi:latest" <

fb4ff5976e9b6b7030d8dae81c6ec23ae6cd654aef443b224cf13a05ac1dd968

Terminal will be reused by tasks, press any key to close it.

Terminal 3 (Python Debug Console): empty

At first I did not use docker-compose, after reading a few issues here I added the files as following and performed "compose up" on docker-compose.debug and then F5, but same result:

version: '3.4'

services:
  gisapi:
    image: gisapi
    build:
      context: .
      dockerfile: ./Dev.Dockerfile
    command: ["sh", "-c", "pip install debugpy -t /tmp && python /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 -m flask run --no-debugger --no-reload --host 0.0.0.0 --port 8090"]
    ports:
      - 8090:8090
      - 5678:5678
    environment:
      - FLASK_APP=gisapi/__init__.py

Do I need docker compose?
If I run "compose up" it just gives me


 > Executing task: docker-compose -f "docker-compose.debug.yml" up -d --build <

Pushing the restart button gives me "There is already a debug configuration "Docker: Python - Flask" running.
Pushing stop seems to stop whatever it is doing in VS code but the docker container is still running (probably supposedly so?)

docker inspect bridge --format="{{(index .IPAM.Config 0).Gateway}}"
gives me
172.17.0.1

And docker inspect:

[
    {
        "Id": "fb4ff5976e9b6b7030d8dae81c6ec23ae6cd654aef443b224cf13a05ac1dd968",
        "Created": "2021-02-10T08:59:13.393043989Z",
        "Path": "python",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 121021,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2021-02-10T08:59:13.80107974Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:ba5808d80a8de6e5a9e33651bad667c07a38a8ce4132947de0406ec6932af6c3",
        "ResolvConfPath": "/var/lib/docker/containers/fb4ff5976e9b6b7030d8dae81c6ec23ae6cd654aef443b224cf13a05ac1dd968/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/fb4ff5976e9b6b7030d8dae81c6ec23ae6cd654aef443b224cf13a05ac1dd968/hostname",
        "HostsPath": "/var/lib/docker/containers/fb4ff5976e9b6b7030d8dae81c6ec23ae6cd654aef443b224cf13a05ac1dd968/hosts",
        "LogPath": "/var/lib/docker/containers/fb4ff5976e9b6b7030d8dae81c6ec23ae6cd654aef443b224cf13a05ac1dd968/fb4ff5976e9b6b7030d8dae81c6ec23ae6cd654aef443b224cf13a05ac1dd968-json.log",
        "Name": "/gisapi-dev",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/home/mtoman/geoserver/gisapi:/app",
                "/home/mtoman/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/lib/python/debugpy:/debugpy:ro"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "8090/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "8090"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": true,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/c8b99ea2411621fa05c2791bbf31ab18428b41287ef4711688103175748576c8-init/diff:/var/lib/docker/overlay2/f1faa8d71b19042fecc4246c2467ae96abdc2c89483591e2985e0dace20e9335/diff:/var/lib/docker/overlay2/3b210411b473609ac873f9b45fcd649efb0ccb51b824dcb7de2c5c03e118a83d/diff:/var/lib/docker/overlay2/6b913b03610cc054090c634f1e74bd7c1781ed69a6697aa0f7a73c27e660a216/diff:/var/lib/docker/overlay2/9bc9e12b9cb1095dff69300a56cfbd36f96e6616360f64dff5c635cebbfa9c6c/diff:/var/lib/docker/overlay2/7628c925f1f3641bf7c9a4d9bb66a6948eed2dbf1d348cc055e46300934db93e/diff:/var/lib/docker/overlay2/0f27688dc844d5aa4c5c510bf2a47ae09c236c40c49d8e2b2785edd8690de796/diff:/var/lib/docker/overlay2/a36d228aea208ce2b00f1d6e2500b489cb646aacdf843f9ad65189de8435c7f1/diff:/var/lib/docker/overlay2/5715b1171416b42dffa96414cd8456b641bf79a56ed384cc34a6d15fe9cb8ad7/diff:/var/lib/docker/overlay2/6a36834e85e25c117c9290ab87289f93a224d16c12f0d91ed553fff241290a1f/diff:/var/lib/docker/overlay2/79e743effc0ff392e8d760133a7ebe8e04a338c7330ed529747bb24bbbe25e91/diff:/var/lib/docker/overlay2/5d0ddab45a5ca4ac042a108ee850cf0463a4768280e2e8ffa0ae2b27b6e43e05/diff:/var/lib/docker/overlay2/f06ac4ff91b32e24b85e75b3de116cf925c3afcd5883f09feadcabfddf47137c/diff:/var/lib/docker/overlay2/0ffee031557ea51579e40a74261051e499a77949e02fc968598b9129e2fa7493/diff:/var/lib/docker/overlay2/7f4001cad9901f2c25f2c72314dfd1e3bd483286f32b16b077ae4904472ef24c/diff:/var/lib/docker/overlay2/9f2dd16e78e4a5f4bf4e5fa9838b946c55484d8a0e252bfe510744f5a3e7c010/diff:/var/lib/docker/overlay2/3d9cb408db638d2fbba1402e349a2b5f74c088be728f427b572b898a5f4d8746/diff:/var/lib/docker/overlay2/374eeee9bfcc51f4376b726d32ed96c7ba182c6ce082d3315f99bbf7df606dca/diff:/var/lib/docker/overlay2/7fbdc0be731517c6c1cefb87bedc94263a06a272fddd084bec328fb5a9ad2818/diff:/var/lib/docker/overlay2/52a31f03fbd3c0734f3a1e81f060d6620155272e58b92e17e10eaea2a93db116/diff:/var/lib/docker/overlay2/4a124dba93305e13c902aeb5adec0bc5a3056a30eb8466eabc05663b69b66f89/diff:/var/lib/docker/overlay2/426212026de255e39b06f112ceef8230f947a61ebd62515f9c7f8955b0cc3710/diff:/var/lib/docker/overlay2/fdc964e3a2e135139456342406e1050c2523d041db9a33cb78170a066f8cff62/diff:/var/lib/docker/overlay2/7bb457a3eb476c22175e114cffb54312f7dca4482a213999ed2ed4e1b4564251/diff:/var/lib/docker/overlay2/c0412af277431ef260ec862188f39f7ab86dbb828058371648f61c1623696812/diff:/var/lib/docker/overlay2/e979eb71f42f34d79a56aa61af0bf6e02e598168bce4c6efb4ad9e5e9da16108/diff:/var/lib/docker/overlay2/39285f50fbdbe12cc29171bd7d07718ca593694bd448d62b36c27d86766ad705/diff:/var/lib/docker/overlay2/c72d9c333f45c912026baa840100302660874af0b92c5b7dc2085f9aee9170f8/diff",
                "MergedDir": "/var/lib/docker/overlay2/c8b99ea2411621fa05c2791bbf31ab18428b41287ef4711688103175748576c8/merged",
                "UpperDir": "/var/lib/docker/overlay2/c8b99ea2411621fa05c2791bbf31ab18428b41287ef4711688103175748576c8/diff",
                "WorkDir": "/var/lib/docker/overlay2/c8b99ea2411621fa05c2791bbf31ab18428b41287ef4711688103175748576c8/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/home/mtoman/geoserver/gisapi",
                "Destination": "/app",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/home/mtoman/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/lib/python/debugpy",
                "Destination": "/debugpy",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "fb4ff5976e9b",
            "Domainname": "",
            "User": "appuser",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "8090/tcp": {}
            },
            "Tty": true,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "FLASK_APP=gisapi/__init__.py",
                "FLASK_ENV=development",
                "GISAPI_SETTING=/app/gisapi/settings_test.cfg",
                "GISAPI_LOGFILE=/var/log/gisapi.log",
                "PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "LANG=C.UTF-8",
                "GPG_KEY=0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D",
                "PYTHON_VERSION=3.6.12",
                "PYTHON_PIP_VERSION=21.0.1",
                "PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/4be3fe44ad9dedc028629ed1497052d65d281b8e/get-pip.py",
                "PYTHON_GET_PIP_SHA256=8006625804f55e1bd99ad4214fd07082fee27a1c35945648a58f9087a714e9d4",
                "PYTHONDONTWRITEBYTECODE=1",
                "PYTHONUNBUFFERED=1"
            ],
            "Cmd": null,
            "Image": "gisapi:latest",
            "Volumes": null,
            "WorkingDir": "/app",
            "Entrypoint": [
                "python"
            ],
            "OnBuild": null,
            "Labels": {
                "com.microsoft.created-by": "visual-studio-code"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "df3bef31eafda3d23fdce090a3f981da7ee449e8acdc7b199ad2ad02fa0e7c5b",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "8090/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "8090"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/df3bef31eafd",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "b6d21ed7c0b0d9f3e66983366ef5acdeaa391663c86fdf0e58c207fbf52d38b4",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "eec3d6222fee208f46be648d684daee193314060167e9fbad637216ecbd4104a",
                    "EndpointID": "b6d21ed7c0b0d9f3e66983366ef5acdeaa391663c86fdf0e58c207fbf52d38b4",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]


Thanks!

EDIT: Dev.Dockerfile:

# For more information, please refer to https://aka.ms/vscode-docker-python
#FROM python:3.8-slim-buster
FROM python:3.6

RUN apt-get update
RUN apt-get install -y apt-utils 
# TODO: fix versions
RUN apt-get install -y libgdal-dev
RUN apt-get install -y libmapnik-dev
RUN apt-get install -y mapnik-utils
RUN apt-get install -y libboost-python-dev gcc

RUN pip install flask
RUN pip install pygdal==`gdal-config --version`.*
RUN pip install owslib
RUN pip install psycopg2-binary
RUN pip install gevent

#== mapnik
# TODO archive not maintained, get via git clone?
RUN wget https://github.com/mapnik/python-mapnik/archive/v3.0.16.tar.gz && \
     tar -xf v3.0.16.tar.gz && rm v3.0.16.tar.gz && \
     cd python-mapnik-3.0.16 && \
     python setup.py install

EXPOSE 8090

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

# Install pip requirements
COPY requirements.txt .
RUN python -m pip install -r requirements.txt

WORKDIR /app

# Switching to a non-root user, please refer to https://aka.ms/vscode-docker-python-user-rights
RUN useradd appuser && chown -R appuser /app
RUN touch /var/log/gisapi.log && chown appuser /var/log/gisapi.log
USER appuser

# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["python", "-m", "flask", "run", "--host", "0.0.0.0", "--port", "8090"]

EDIT2:
ping 172.17.0.1 and ping 172.17.0.2 works.

@bwateratmsft
Copy link
Collaborator

I tried it out with mostly the same stuff you have (albeit once on Windows and once in Linux Codespaces) and was successful. Is there a Python interpreter selected in the lower left?
image

Is there any difference in the output if you do:

python --version

vs.

python3 --version

Compose debugging is an alternative but I'm not sure if hot reloading will work. In the docker launch configuration we don't pay any attention to the compose files; just the Dockerfile. To debug an app started with compose, you compose up the docker-compose.debug.yml file, and instead of running the docker launch configuration, you do a python attach one. This is covered in the docs here though I wish there was better linking between these doc pages...

{
    "name": "Python: Remote Attach",
    "type": "python",
    "request": "attach",
    "port": 5678,
    "host": "localhost",
    "pathMappings": [
        {
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/app"
        }
    ]
}

@m-toman
Copy link
Author

m-toman commented Feb 10, 2021

Thanks!
OK I don't need/want docker-compose, just wasn't sure if it's needed.

Do you mean the python version on the host machine?
On that I got

python --version
Python 3.7.4
python3 --version
Python 3.7.4

That's an anaconda installation.

Once I press F5 it also shows this python version
image

Interestingly I also got the option to pick this "geoserver conda" version (geoserver is my project) and no idea where that comes from:
image

EDIT: OK the following happened because I added a workspace

image

OK found this #2327 - removed the workspace again (created it today because I wanted to ship the final thing to the client as a workspace, but fine without it as well).
Error message gone again

@bwateratmsft
Copy link
Collaborator

@int19h I forgot how to turn on the extra diagnostics so we could see what's happening with Python debug--can you remind us?

@m-toman
Copy link
Author

m-toman commented Feb 12, 2021

So as I see it, it doesn't run my task at all. At least it outputs it nowhere.
Tested something like this but after docker build/run it seems to never exec the python task:

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "docker-build",
			"label": "docker-build",
			"platform": "python",
			"dockerBuild": {
				"tag": "gisapi:latest",
				"dockerfile": "${workspaceFolder}/Dev.Dockerfile",
				"context": "${workspaceFolder}",
				"pull": true
			}
		},
		{
			"type": "docker-run",
			"label": "docker-run: debug",
			"dependsOn": [
				"docker-build"
			],
			"dockerRun": {
				"env": {
					"FLASK_APP": "gisapi/__init__.py",
					"FLASK_ENV": "development",
				},
				"volumes": [
					{
						"containerPath": "/app",
						"localPath": "${workspaceFolder}"
					}
				],
				"ports": [
					{
						"containerPort": 8090,
						"hostPort": 8090,
						"protocol": "tcp"
					}
				]
			},
			"python": {
				"file": "tests/test_route.py"
			}
		}
	]
}

image

Output etc. all empty.
BTW if I run it with this task, would it always attach a debugger?

EDIT: Also interesting: when I go to the docker tab and right-click the container and try "show logs" or "attach shell" it prints the command in the terminal but never get a response

image

Inspect works and opens a new file with the results.

Running docker logs from my regular linux terminal shows me that the "dummy" interpreter is running:
``
docker logs gisapi-dev
Python 3.7.9 (default, Feb 9 2021, 08:33:04)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

@bwateratmsft
Copy link
Collaborator

Yeah, I've seen that behavior--where the docker-build and docker-run tasks execute, but then nothing seems to happen. It's been when the Python extension gets confused for one reason or another about what it's supposed to be doing as far as debugging (the way our debug code works is we start up the container, then resolve a python debug configuration which hands off to the Python extension). @int19h showed me a way to get extra diagnostic logging from Python that helped in the past with determining what went wrong, but I can't remember how it's done...

@dbreshears dbreshears added this to the 1.12.0 milestone Feb 17, 2021
@ucheNkadiCode
Copy link
Contributor

TODO: @bwateratmsft Will make a small prototype of a flask app that does not emit an output to find a debugging issue.
Subsequently, I will create a meeting with the Python team to brainstorm this issue with users since it has occurred in multiple issues now.

@m-toman
Copy link
Author

m-toman commented Feb 17, 2021

Quick info from my side: meanwhile setup up Windows with WSL2 based docker and it worked without any issues or modifications.

@bwateratmsft
Copy link
Collaborator

We just released extension version 1.10.0, which included some changes in this space to make WSL debugging work better. Are you on 1.10.0 now (for that attempt on Windows where it worked)? Can you try again on Linux with 1.10.0 and see if there's any change?

@m-toman
Copy link
Author

m-toman commented Feb 17, 2021

Windows is running 1.10.0, although I'm not fully sure if it did an auto-update since I tested it a few days ago.
Linux 1.9.1.
Updated to 1.10.0 but still seems same behavior.

@bwateratmsft
Copy link
Collaborator

bwateratmsft commented Apr 1, 2021

Hey @m-toman, sorry for the slow response, we've been super busy lately. We met with the Python debugger folks and they had a few things to try out. Meanwhile, they've opened microsoft/debugpy#579.

  1. In .vscode/launch.json, add the property "logToFile": true to the debug config, like this (you can ignore the warning/yellow squiggles):
    image
  2. In .vscode/tasks.json, we'll set an environment variable to log in the container side, in the docker-run task (I chose /app/logs but you can choose a different spot):
    image
  3. Try debugging, hopefully the bug reproduces again.
  4. From the host side, you should be able to find two logs at ~/.vscode/extensions/ms-python.python-xxxx.x.xxxx, with titles like debugger.vscode_baadf00d...log and debugpy.adapter-xxxxx.log, can you upload both of those? You can quickly reach the ~/.vscode/extensions folder using the Extensions: Open Extensions Folder VSCode command.
    image
  5. The container should be running. You can use the files browser to locate any logs, however I do not expect there to be any files here (we don't think debugpy is ever starting within the container). Still, if there are any logs, can you upload those as well?
    image

@m-toman
Copy link
Author

m-toman commented Apr 1, 2021

Thanks, good timing as I am likely back working on the service next week.
The devs of my client use Windows and for them things worked out by just loading the project I sent them and pushing F5, running via WSL - really great.

@m-toman
Copy link
Author

m-toman commented Apr 2, 2021

OK I quickly tried it, @bwateratmsft
I got the two files and attached them. Look pretty innocent to me but that's just me ;).
As you suspected, no /app/logs inside the container to be found.

debugger.vscode_9e59d0c5-6125-4204-a225-7e99e0a97300.log
debugpy.adapter-352754.log

@bwateratmsft
Copy link
Collaborator

@int19h Nothing sticks out to me in those logs; there isn't any error similar to what we tried yesterday. Any ideas?

@bwateratmsft
Copy link
Collaborator

I'm going to convert this to a discussion. As far as we can tell there's not a bug in the Docker extension; andhttps://github.com/microsoft/debugpy/issues/579 has been opened in debugpy. I'd still like to get to the bottom of what's happening, though.

@microsoft microsoft locked and limited conversation to collaborators Apr 7, 2021
@bwateratmsft bwateratmsft removed this from the 1.13.0 milestone Apr 7, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

4 participants