Setting up Docker Development Environment: Installing Tools and Using VSCode Remote Development

Abstract: Eliminate configuration drift by establishing a consistent Docker development environment using VSCode Remote-Containers for isolated, reproducible coding.

Created: 2026-08-26 by
You can establish a consistent Docker development environment by installing the Docker Desktop application and the Remote - Containers extension in Visual Studio Code. This setup allows you to write code locally while executing it inside an isolated container, ensuring that dependencies are identical across all team members and eliminating configuration drift between local machines and production servers.

Prerequisites and Installation

To begin, ensure your operating system meets the requirements for running virtualization software. For Windows users, Hyper-V or WSL 2 must be enabled. On macOS, Apple Silicon or Intel processors are supported via Docker Desktop. The first step is downloading the installer from the official Docker website. Run the installer and follow the prompts to complete the initial setup. Once installed, verify the installation by opening a terminal and running docker --version. You should see the version number outputted without errors.

Next, launch Visual Studio Code. Navigate to the Extensions view by clicking the square icon on the sidebar or pressing Ctrl+Shift+X. Search for the "Remote - Containers" extension published by Microsoft. Click Install to add this capability to your editor. This extension is crucial as it provides the interface between VSCode and the Docker daemon, allowing the editor to attach to running containers seamlessly.

Configuring the Development Container

A development container is defined by a devcontainer.json file located in a folder named .devcontainer at the root of your project. Create this folder in your project directory. Inside, create the JSON file. The most basic configuration requires specifying an image. For example, if you are developing in Python, you might use mcr.microsoft.com/devcontainers/python:1.

{
  "name": "Python Development",
  "image": "mcr.microsoft.com/devcontainers/python:1",
  "features": {
    "ghcr.io/devcontainers/features/git:1": {}
  }
}

This configuration tells VSCode to pull the specified image and start a container based on it. The features object allows you to install additional tools like Git, Node.js, or Docker-in-Docker without writing a custom Dockerfile. This approach keeps your project lightweight while providing necessary utilities. If your project requires specific system packages, you can add a postCreateCommand to run setup scripts after the container starts.

Connecting to the Container

Once the devcontainer.json file is saved, VSCode will detect it. A notification will appear in the bottom right corner asking if you want to reopen the folder in a container. Click Reopen in Container. Alternatively, you can press F1 to open the command palette and select Remote-Containers: Reopen in Container. VSCode will build the container using the provided image and features.

During this process, you may notice a brief delay as images are pulled and layers are extracted. After completion, the status bar at the bottom left will change to indicate that you are connected to the remote container. Your terminal within VSCode will now be running inside the container. Any commands you execute here, such as pip install or npm install, will affect the container's filesystem, not your host machine. This isolation ensures that your host OS remains clean and free of development clutter.

If you need to access services running inside the container, such as a database or API server, VSCode automatically forwards ports. You can view forwarded ports in the Ports panel. This feature simplifies debugging and testing, as you can interact with internal services using localhost addresses just as you would on a physical machine.

Best Practices for Efficiency

While containers provide isolation, they can consume significant disk space if not managed properly. Regularly prune unused images and volumes using docker system prune to reclaim storage. Additionally, consider using multi-stage builds in your Dockerfiles if you switch to custom configurations later. This reduces the final image size and improves build times.

Version control your devcontainer.json file along with your source code. This ensures that every developer on your team uses the exact same environment. It eliminates the common issue of "it works on my machine" by standardizing the development stack. For teams working on complex microservices architectures, this consistency is invaluable for maintaining productivity and reducing onboarding time for new engineers.

For more advanced scenarios involving volume mounts, you can configure VSCode to sync files between your host and the container. This allows you to edit files on your host machine using any text editor while still having them available in the container. However, for most simple projects, relying on the container's filesystem is sufficient and safer.

Frequently Asked Questions

Why is my container taking so long to start?

The initial startup is slow because Docker needs to pull the base image and download any specified features from the registry. Subsequent startups are much faster because these layers are cached locally on your machine. You can speed up future launches by ensuring you have a stable internet connection during the first setup.

Can I use multiple containers for one project?

Yes, you can define a docker-compose file alongside your devcontainer configuration. VSCode supports connecting to services defined in a compose file, allowing you to develop against databases or message queues running in separate containers. This is ideal for full-stack applications that require external dependencies.

How do I debug code running inside the container?

You can configure launch configurations in VSCode to attach to the running container process. Set breakpoints in your code as usual, and the debugger will connect directly to the container's runtime. Ensure that the debugger extension for your language is installed inside the container by adding it to your features or Dockerfile.

What happens to my data when I stop the container?

Data stored in the container's filesystem is lost when the container is removed. To persist data, you must mount a volume from your host machine into the container. This can be configured in the devcontainer.json file under the mounts property, ensuring your code and database files survive container restarts.

Is there a performance penalty compared to native development?

There is a slight overhead due to virtualization, but for most development tasks, the difference is negligible. File system operations may be slower depending on your OS and Docker configuration, particularly on Windows with WSL 2. Using fast SSDs and optimizing your volume mounts can mitigate these minor performance impacts effectively.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More