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

推荐订阅源

GbyAI
GbyAI
博客园 - 三生石上(FineUI控件)
S
Securelist
U
Unit 42
The Cloudflare Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Simon Willison's Weblog
Simon Willison's Weblog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
B
Blog
T
Tenable Blog
The Hacker News
The Hacker News
The Register - Security
The Register - Security
IT之家
IT之家
博客园 - 【当耐特】
Spread Privacy
Spread Privacy
P
Privacy & Cybersecurity Law Blog
博客园_首页
T
Tailwind CSS Blog
人人都是产品经理
人人都是产品经理
C
Cybersecurity and Infrastructure Security Agency CISA
Know Your Adversary
Know Your Adversary
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
T
Tor Project blog
C
CERT Recently Published Vulnerability Notes
Apple Machine Learning Research
Apple Machine Learning Research
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
V
Vulnerabilities – Threatpost
A
Arctic Wolf
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
V
V2EX
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Cyberwarzone
Cyberwarzone
V
Visual Studio Blog
月光博客
月光博客
爱范儿
爱范儿
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
美团技术团队
G
GRAHAM CLULEY
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Heimdal Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Docker for Data Professionals: From Zero to Containerizing Your First Project
Lawrence Mur · 2026-05-11 · via DEV Community

Introduction

If you work with data, you probably have spent hours writing a Python script, training a machine learning model or building a data pipeline. It runs perfectly on your laptop but when you send the same code to a teammate or try to run it on a company server, it instantly crashes.
Usually, the error has nothing to do with your code. It crashes because of issues like; the other computer has a different version of Python, is missing a library like pandas, or uses a different operating system.
Docker was created to solve this exact problem.
This article delves into what Docker is, why data scientists and analysts should care about it, and how to use it step-by-step.

What is Docker?

Before the 1950s, global shipping was a mess. Loading and unloading a ship was a nightmare(slow and unstandardized) because contents such as barrels, sacks, cars and boxes were different shapes weights and size.
Then, the shipping industry invented the steel shipping container. It didn't matter if you were shipping cars, coffee, or electronics, you just put your contents in a standard box. Ships, trains, and cranes were now built to handle that box.
Docker does the exact same thing for software.
Instead of just moving your code from one computer to another, Docker allows you to package your code, the programming language, the exact libraries you used, and the system settings into one standard box.
Because everything your code needs is inside that box, it will run exactly the same way on your laptop, your coworker's laptop, or a cloud server.

Docker vs. Virtual Machines

You might be thinking, Isn't that just a Virtual Machine(VM)?
It’s a fair assumption, as both provide isolated environments for your applications, but Docker is fundamentally lighter and more efficient.
A traditional VM relies on software called a hypervisor to bundle your code and libraries with a complete, dedicated guest operating system. Booting up a whole new copy of Windows or Linux makes VMs massive, resource-heavy, and slow to start.
However, Docker only virtualizes the application layer. It uses a background service called the Docker Engine to share your host computer's underlying operating system. By stripping away the bulky guest OS, Docker packages only the absolute essentials; the code, runtime, and settings, into a highly portable container. This isolation guarantees your app will run reliably across any infrastructure. Docker containers also take up a fraction of the disk space and launch in mere seconds.

Core Docker Terminologies

Before writing any code, it's critical to understand the basic vocabulary of the Docker ecosystem.
1. Docker Engine - This is the underlying background program running on your machine. It does the actual heavy lifting required to build, run and manage your containers.
2. Dockerfile - Think of this as a recipe. It is a plain text document that contains a step-by-step list of commands. Docker reads this file to know exactly which software to install and which files to copy to build your environment.
3. Images - An image is a frozen, unchangeable blueprint created by running a Dockerfile. It holds your code, tools, and system libraries in one package. Images are used to spawn active containers. Think of it as the static mold used to make identical products.
4. Containers - This is the live, running version of an image. A container isolates your application and its requirements from the rest of your computer, guaranteeing it behaves the exact same way no matter what machine it runs on.
5. Docker Hub - This is a massive online library for Docker images. Just like GitHub is used for sharing code, Docker Hub is a public platform where people can upload their own custom images or download pre-made environments to save time.
6. Volumes - Because containers are temporary, any data saved inside them is lost when they shut down. Volumes fix this by linking a folder inside the container to a folder securely saved on your actual hard drive, preventing data loss.
7. Networks - This is the system that allows multiple standalone containers to talk to each other safely. For example, a network lets a container holding your Python code securely send data to a separate container running a database.

Why Data Professionals Need Docker

While Software developers have used Docker for years to run websites, it has now become a required skill for data teams because of various reasons.
• Reproducibility - In data science, if someone cannot reproduce your results, your results are not valid. Docker guarantees that anyone who runs your container will get the exact same output.
• Easy Handoffs - A Predictive model is usually handed over to a data engineer or a software team to put it into production. A Docker container would easen their work since they don't have to guess how to set up the environment. They just run it.
• Working with Old Code - Sometimes you need to run a script written three years ago using Python 3.6. Instead of messing up your current computer by downgrading your software, you just spin up a Docker container with the old versions, run the job, and delete it.

Pros of Using Docker

1. Portability
Docker packages your application along with all its dependencies, libraries, and configuration files into a single image. Because the environment is locked inside this image, the application will run exactly the same way on a developer's laptop, a testing server, or in the production cloud. It eliminates the problem of "It Works on My Machine".
2. Resource Efficiency
Traditional Virtual Machines (VMs) require a full, heavy guest Operating System for every application. Docker containers, however, share the host machine's OS kernel thus are incredibly lightweight, take up significantly less hard drive space, and can start up in milliseconds. You can also run many more containers on a single server than you could VMs.
3. Isolation of Environments
Every container runs in its own isolated environment. This means you can have one container running an application that requires Python 2.7, and another container running an application that requires Python 3.10 on the exact same server.
4. Ideal for Microservices and Scalability
Docker is the foundation for modern microservices architectures. Instead of building one massive, monolithic application, you can build small, independent services (e.g., a database container, a web server container, an authentication container). If your web traffic spikes, you can quickly spin up 10 extra web server containers without having to duplicate the database.
5. Faster Deployment and CI/CD Integration
Docker images are pre-configured thus deploying them is as simple as downloading the image and pressing run. This makes Docker incredibly popular for Continuous Integration/Continuous Deployment (CI/CD) pipelines. If a new version of an app has a bug, rolling back is as easy as running the previous Docker image tag.

Cons of Using Docker

1. Steep Learning Curve
For beginners, Docker introduces a lot of new concepts hence takes time to become proficient. Developers have to learn how to write Dockerfiles, manage docker-compose configurations, understand container networking (how containers talk to each other), and grasp how images are built.
2. Data Persistence Complexity
By design, containers are ephemeral (temporary). If a container is deleted or crashes, all the data inside it is permanently lost. To save data permanently (like a database), you have to learn how to manage Docker Volumes or Bind Mounts to connect container storage to the host machine's hard drive.
3. Cross-Platform Performance and Quirks
Docker is natively a Linux technology. While Docker Desktop allows you to run it on macOS and Windows, it actually does this by running a lightweight, hidden Linux Virtual Machine in the background. This can lead to heavy RAM/CPU usage on Mac and Windows machines, and file-syncing between the host and the container can sometimes be slow.
4. Security Concerns (Shared Kernel)
Because containers share the host's Operating System kernel, they are less isolated than full Virtual Machines. If a hacker finds a vulnerability in the host OS kernel, they might be able to break out of the container and access the host machine or other containers. Additionally, poorly configured containers running as the root user pose a significant security risk.
5. Not Ideal for Desktop/GUI Applications
Docker is heavily optimized for backend services, APIs, databases, and command-line tools. While it is technically possible to run graphical desktop applications (GUI) inside Docker, it is highly complex, clunky, and generally not recommended.

First Docker Project

Let’s build a simple data project and put it inside a Docker container.

Step 1: Install Docker
Download Docker Desktop for Windows, Mac, or Linux here. Docker Desktop is a helpful graphical interface that includes the underlying Docker Engine. Install it and open the application. It runs quietly in the background.

Step 2: Set Up Your Project Files
Create a new folder on your computer e.g. myproject. Inside this folder, create three files.
File 1: main.py
This is the Python script. Write a simple program that uses the pandas library to create a small dataset and print it out.

import pandas as pd

data = {
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [25, 30, 35],
    'Role': ['Data Analyst', 'Data Engineer', 'Data Scientist']
}

df = pd.DataFrame(data)

print("--- Team Data ---")
print(df)

Enter fullscreen mode Exit fullscreen mode

File 2: requirements.txt
This file tells Python which libraries are needed. Since pandas was used, list it here.

pandas==2.1.0

Enter fullscreen mode Exit fullscreen mode

File 3: Dockerfile
This is the magic file. Create a file named Dockerfile. Open it in a text editor and paste the following code.

# 1. Start with a base image pulled from Docker Hub that already has Python
FROM python:3.10-slim

# 2. Create a working directory inside the container
WORKDIR /app

# 3. Copy our requirements file into the container
COPY requirements.txt .

# 4. Install the libraries listed in requirements.txt
RUN pip install -r requirements.txt

# 5. Copy the rest of our code into the container
COPY main.py .

# 6. Tell the container what to do when it starts
CMD ["python", "main.py"]

Enter fullscreen mode Exit fullscreen mode

Step 3: Build the Docker Image
Now, turn those three files into a Docker Image.
Open your computer's terminal (Command Prompt on Windows, Terminal on Mac/Linux) and navigate to the myproject folder and run the below command.

docker build -t my-first-data-app .

Enter fullscreen mode Exit fullscreen mode

NB: The period . at the end tells Docker to look for the Dockerfile in the current folder.
• docker build tells Docker to read the recipe.
• -t my-first-data-app gives the image a name (tag) so it can be easier to find it later.

Step 4: Run the Container
Once the build is finished, the image is ready and can be run using the command below.

docker run my-first-data-app

Enter fullscreen mode Exit fullscreen mode

This displays the output of the Python script on the screen.

--- Team Data ---
      Name  Age            Role
0    Alice   25    Data Analyst
1      Bob   30   Data Engineer
2  Charlie   35  Data Scientist

Enter fullscreen mode Exit fullscreen mode

The Image can now be sent to anyone in the world, and it would print the exact same table, even if they don't have Python installed on their computer.

The Multi-Container Problem

Running a single container is great. However, modern applications are rarely just one piece of software.
A standard web application usually consists of:

  • A frontend application
  • A backend API
  • A database
  • A caching system

Using basic Docker commands means you have to build and run each of these containers manually, figure out how to connect them to the same network so they can talk to each other and manage their startup order. Doing this by typing long commands into the terminal every single day is frustrating and prone to human error.

Docker Compose

Docker Compose is a tool designed specifically to solve the multi-container problem.
Instead of typing a bunch of manual terminal commands, Docker Compose allows you to define your entire multi-container application in a single text file called docker-compose.yml.
YAML (Yet Another Markup Language) is just a way to write configuration data in a clean, readable format using indentation.
With Compose, you define services. Each service represents one container in your application setup. You can define what image the service should use, what ports it should open, and how it connects to the other services.

A Practical Docker Compose Example

# The structure of docker compose

services:
  app:
    build: .
    ports:
      - "8080:8080"

  postgres:
    image: postgres
    ports:
      - "5432:5432"

Enter fullscreen mode Exit fullscreen mode

services:
  postgres:
    image: postgres:latest
    container_name: postgres
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: 12345
      POSTGRES_DB: postgres
    ports:
      - "5433:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 15s
      timeout: 10s
      retries: 5

  etl:
    build: .
    container_name: etl
    environment:
      DB_USER: postgres
      DB_PASSWORD: 12345
      DB_HOST: postgres
      DB_PORT: 5432
      DB_NAME: postgres
    depends_on:
      postgres:
        condition: service_healthy

Enter fullscreen mode Exit fullscreen mode

Let's break it down.
services - We have two services defined; postgres (the database) and etl (the process interacting with the database).
image - For the postgres service, we are not building our own image. We are downloading the official postgres:latest image directly from Docker Hub.
container_name - Explicitly sets the names of the running containers to postgres and etl instead of letting Docker auto-generate random names.
environment - This passes variables (like passwords and database names) into the containers. The etl service's DB_HOST is simply postgres. Docker Compose automatically creates a network so the etl container can talk to the database using its service name.
ports - Maps port 5433 on your host machine to port 5432 inside the postgres container. This allows you to connect to the database from outside of Docker using port 5433.
healthcheck - Tells Docker how to test if the postgres database is actually ready to accept connections. It runs the command pg_isready every 15 seconds, waiting up to 10 seconds for a response, and will try 5 times before failing.
build - For the etl service, we tell Compose to look in the current folder (.) for a Dockerfile and build the image from scratch.
depends_on - This tells Docker not to start the etl service until the postgres container is fully up and has successfully passed its healthcheck (condition: service_healthy).

Once you have written the above file, you can start your entire application; the database, the custom network, and the backend with just one command as below.

docker-compose up

Enter fullscreen mode Exit fullscreen mode

When you are done working and want to shut everything down and clean up the network, you type

docker-compose down

Enter fullscreen mode Exit fullscreen mode

Using Docker Volumes for Data

Volumes persist data outside of the container's lifecycle. Why is this important for data professionals?
In the example above, we packed our Python script directly into the container. But what if you are processing a 10-gigabyte CSV file? You do not want to pack a massive data file inside your Docker image. Images are supposed to be lightweight. Furthermore, if your code generates a cleaned CSV, and the container stops running, that new file will be lost forever.
A Volume fixes this by acting as a bridge between your actual computer and the container.
Imagine you have a folder called data on your laptop, and you want your Docker container to read a file inside it. You would run your container like this:

docker run -v /path/to/your/local/data:/app/data my-first-data-app

Enter fullscreen mode Exit fullscreen mode

The -v command maps a folder on your computer to a folder inside the container. Now, your Python script can read heavy datasets and save output files directly to your laptop, without making the Docker image bloated.

Summary

Docker is an incredibly powerful tool that has revolutionized software engineering by making apps fast, portable, and scalable. However, for a very simple, static website or a solo developer building a basic script, adding Docker might introduce unnecessary complexity and overhead.
If you want to start using Docker in your daily data work, ensure to follow these rules.
1. Use official base images - When writing a Dockerfile, always start with an official image from Docker Hub like python:3.10-slim or jupyter notebook. They are secure and well-maintained.
2. Keep it small - Use versions of Linux that have slim or alpine in the name. They take up less space on your hard drive.
3. Pin your versions - Always use a requirements.txt file and specify the exact version of the library you used (e.g., scikit-learn==1.3.0). If you just write scikit-learn, Docker will download the newest version, which might break your code.
4. Don't put passwords in Dockerfiles - If your script connects to a database, never hardcode your password into the script or the Dockerfile. Use environment variables instead.
5. Level up with Docker Compose - Once you are comfortable running a single container, look into Docker Compose. While Docker commands handle individual containers, Docker Compose allows you to define and manage multi-container applications. By writing a single docker-compose.yml file, you can seamlessly utilize Networks to connect multiple containers e.g. running Python script in one container and a PostgreSQL database in another and spin them all up with just one simple command (docker-compose up).
Mastering Docker could save you hundreds of hours of debugging. Once you learn how to containerize your data projects, "it works on my machine" will be a phrase you never have to say again.