Skip to content

Dockerrun task overwrites docker entry point with just python3 call not my app invokation  #3641

@Jan-Kowalik-mulberryrisk

Description

I followed a tutorial for Python in container running and debugging on VSCode from here. But the docker launch configuration that VSCode generates for me does not work. When I start it de launch config with F5 the container entry point is overwritten with a call to python3 only. It does not start my app at all. Please advice, is that a bug in the docker extension?

See more details on my config below. It is all standard generated and not really modified.
In terminal output you can see that it sets entry point to python3

Environment:

  • Win11
  • VSCode 1.72.2
  • Docker extension 1.22.1

Auto generated files:

  • .vscode/tasks.json
{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "docker-build",
			"label": "docker-build",
			"platform": "python",
			"dockerBuild": {
				"tag": "exceltojson:latest",
				"dockerfile": "${workspaceFolder}/Dockerfile",
				"context": "${workspaceFolder}",
				"pull": true
			}
		},
		{
			"type": "docker-run",
			"label": "docker-run: debug",
			"dependsOn": [
				"docker-build"
			],
			"dockerRun": {
				"env": {
					"FLASK_APP": "app.py"
				}
			},
			"python": {
				"args": [
					"run",
					"--no-debugger",
					"--no-reload",
					"--host",
					"0.0.0.0",
					"--port",
					"5000"
				],
				"module": "flask"
			}
		}
	]
}
  • .vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "app.py",
                "FLASK_ENV": "development",
                "FLASK_DEBUG": "0"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload"
            ],
            "jinja": true
        },
        {
            "name": "Docker: Python - Flask",
            "type": "docker",
            "request": "launch",
            "preLaunchTask": "docker-run: debug",
            "python": {
                "pathMappings": [
                    {
                        "localRoot": "${workspaceFolder}",
                        "remoteRoot": "/app"
                    }
                ],
                "projectType": "flask"
            }
        }
    ]
}
  • Dockerfile
# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.8-slim

EXPOSE 5000

# 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
COPY . /app

# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser

# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
  • Terminal output:
#11 writing image sha256:5f27eedb9f5e02e98a83e24cc30d3496381050d0a4fae0c5d9d2beeff6df78c4 0.0s done
#11 naming to docker.io/library/exceltojson:latest done
#11 DONE 0.2s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: docker-run: debug 

> docker run -dt -P --name "exceltojson-dev" -e "FLASK_APP=app.py" --label "com.microsoft.created-by=visual-studio-code" -v "c:\Users\JanKowalik\.vscode\extensions\ms-python.python-2022.16.1\pythonFiles\lib\python\debugpy:/debugpy:ro,z" --entrypoint "python3" "exceltojson:latest" <

4f811149f9b42456a29b98a6c162bda450a8ba9cf9bf53ab076691fd9ddb6bfb
 *  Terminal will be reused by tasks, press any key to close it. 
  • error dialog:
    image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions