惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
Recorded Future
Recorded Future
云风的 BLOG
云风的 BLOG
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Troy Hunt's Blog
Security Latest
Security Latest
Scott Helme
Scott Helme
Project Zero
Project Zero
C
Cybersecurity and Infrastructure Security Agency CISA
Google DeepMind News
Google DeepMind News
NISL@THU
NISL@THU
Latest news
Latest news
L
Lohrmann on Cybersecurity
P
Palo Alto Networks Blog
V
Vulnerabilities – Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
AWS News Blog
AWS News Blog
S
Schneier on Security
TaoSecurity Blog
TaoSecurity Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
D
DataBreaches.Net
大猫的无限游戏
大猫的无限游戏
W
WeLiveSecurity
Cyberwarzone
Cyberwarzone
T
Threat Research - Cisco Blogs
The Register - Security
The Register - Security
L
LINUX DO - 热门话题
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
B
Blog
D
Docker
Apple Machine Learning Research
Apple Machine Learning Research
P
Privacy & Cybersecurity Law Blog
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
Webroot Blog
Webroot Blog
Martin Fowler
Martin Fowler
The Cloudflare Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
SegmentFault 最新的问题
Vercel News
Vercel News
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog

Lei Mao's Log Book

2026 FIFA World Cup 备受嘲讽的会徽 Vargas Plateau Regional Park 徒步 Vargas Plateau Regional Park Apex 2026 FIFA World Cup 小组赛赛程 Retaining EXIF Metadata In GIMP San Francisquito Creek Joint Powers Authority 2025 Calendar Photo 麦当劳 The FIFA World Cup 套餐 Ardenwood Historic Farm 徒步 Ardenwood Historic Farm Synchronizations With TorchRec KeyedJaggedTensor Pacific Commons Linear Park 徒步 Pacific Commons Linear Park 2026 San Jose Half Marathon 竞赛 目标 Mountain View Shoreline Park 徒步 Mountain View Shoreline Park PyTorch AOTInductor Hybrid Lowering Carquinez Strait Regional Shoreline 徒步 Carquinez Strait Regional Shoreline PyTorch Triton Kernel Transparent Tracing and Compilation 脸庞 PyTorch Fake Export 2026 BRAIN Foundation 10K 竞赛 2026 Wild and Scenic Film Festival 参观 2026 Wild and Scenic Film Festival 系统工程程序员修 Bug FIFA 官方网站的语言 PyTorch Custom Operation 汉堡王 The Mandalorian and Grogu 套餐 Tilden Regional Parks Botanic Garden 参观 Tilden Regional Park Tilden Regional Parks Botanic Garden Tilden Regional Park 徒步 《寻秦记》电影版 ICML 2026 Area Chair Experience 2026 Foster City 5K Fun Run 竞赛 2026 年 3 月和 4 月该入手的模型手办 Docker Container GUI Display Using Wayland 马拉松破二 2026 Heart & Soles Run 5K 竞赛 How Is FARS, The Fully Automated Research System? 算计: 七天的死亡游戏 Lake Chabot Regional Park 徒步 Lake Chabot Regional Park 2023 年恐怖电影《感恩节》 2026 Airport Runway Run at San Carlos Airport 5K 竞赛 Page Table for Page-Locked Host Memory Don Edwards San Francisco Bay National Wildlife Refuge - Ravenswood 徒步 Don Edwards San Francisco Bay National Wildlife Refuge - Ravenswood 法外风云 PyTorch Graph Symbolic Integer Contra Costa Canal Regional Trail 徒步 Contra Costa Canal Regional Trail 娑婆诃 PyTorch Export 2026 Western Pacific 5K 竞赛 浮躁的科研和胡扯的自媒体 Connecting Logitech Devices On Linux 2026 Oakland Half Marathon 竞赛 Del Valle Regional Park 徒步 Del Valle Regional Park CUDA_LAUNCH_BLOCKING=1 踏切时间 Wildcat Canyon Regional Park 徒步 Wildcat Canyon Regional Park Credit Card Unauthorized Transaction While In Possession 莎拉的真伪人生 2026 Union City Superhero Fun Run 5K 竞赛 McLaughlin Eastshore State Park 徒步 McLaughlin Eastshore State Park Cloudflare Worker Proxy R2 Bucket Access Zorro 和 Batman Fix MacBook Pro Space Key Stuck Problem 2026 年 1 月和 2 月该入手的模型手办 2026 Brazen Victory 10K 竞赛 儿时的玩伴李峰 Marsh Creek Regional Trail 徒步 Marsh Creek Regional Trail Perfetto GPU Flow Artifacts 百万人推理 System Performance Optimizations QQ 幻想 2026 Brazen Bay Breeze 5K 竞赛 CUDA Shared Memory Bank Conflict-Free Vectorized Access Dota 闪电站出售 Mountain View Downtown 徒步 Mountain View Downtown C++ Latch and Barrier 2025 年跑步总结 2026 Rotary Mission Ten Half Marathon 竞赛 狗的素质等于人的素质 CUDA Rendezvous Stream Pleasanton Ridge Regional Park 徒步 Pleasanton Ridge Regional Park Xfinity Internet 多年来的使用感受 Randomized SVD Don Castro Regional Recreation Area 徒步 Don Castro Regional Recreation Area 拖车公司的大汉们
Python Debugging Via VS Code In Docker Container
Lei Mao · 2026-06-14 · via Lei Mao's Log Book

Introduction

Debugging is an essential part of software development, and it can be particularly challenging when working with applications running inside Docker containers. Visual Studio Code (VS Code) provides powerful debugging capabilities that can be leveraged to debug Python applications running in Docker containers.

In this blog post, we will explore how to set up Python debugging in VS Code for applications running inside Docker containers.

Example Program

This is a simple Python program with an intentional bug that we will use to demonstrate debugging in VS Code. We could insert breakpoints in the code lines marked with comments, and then use VS Code to step through the code and inspect variables to find the bug.

debug_math.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31


def multiply_by_two(x):

return x * 2

def buggy_sum(arr):


total = 0

for i in range(len(arr) - 1):

total += arr[i]
return total

if __name__ == "__main__":

data = [3, 5, 1, 8, 14]
print("Array:", data)





doubled = [multiply_by_two(x) for x in data]
print("Doubled Array:", doubled)
result = buggy_sum(doubled)
print("Sum:", result)

print("Python sum:", sum(doubled))

Debugging Via Attaching To A Running Container

To start a Docker container for debugging, the Docker container has to have debugpy installed and the port for debugpy (default is 5678) has to be exposed. We can use the following command to start a Docker container with the necessary configurations for debugging:

1
$ docker run -it --rm --gpus all -v $(pwd):/mnt -w /mnt -p 5678:5678 nvcr.io/nvidia/pytorch:26.04-py3

The docker container nvcr.io/nvidia/pytorch:26.04-py3, which has debugpy pre-installed, is used for quick demonstration.

To start the program for debugging in Docker container, we can use the following command to start the debugpy server and wait for the VS Code client to connect:

1
$ python -m debugpy --listen 0.0.0.0:5678 --wait-for-client debug_math.py

In VS Code, with our launch.json where attach and port are configured, we can start debugging by Command Palette Ctrl + Shift + D and hitting F5. This will connect to the debugpy server running in our Docker container, allowing us to set breakpoints and step through our code as if it were running locally.

Debugging In Development Container

To start the development container for debugging, we can use the Remote-Containers: Reopen in Container command via the Command Palette Ctrl + Shift + P in VS Code. This will open the current workspace inside the development container, allowing us to run and debug our code directly within the container environment.

The development container and VS Code extension setups are a little bit more complicated. The reference setup could be found in the GitHub repository for this example.

References