<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Dev Environment on KnightLi Blog</title>
        <link>https://www.knightli.com/en/tags/dev-environment/</link>
        <description>Recent content in Dev Environment on KnightLi Blog</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en</language>
        <lastBuildDate>Thu, 16 Apr 2026 10:20:00 +0800</lastBuildDate><atom:link href="https://www.knightli.com/en/tags/dev-environment/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>Build Docker Images in VS Code on Windows: From Setup to Build</title>
        <link>https://www.knightli.com/en/2026/04/16/vscode-docker-image-build-windows/</link>
        <pubDate>Thu, 16 Apr 2026 10:20:00 +0800</pubDate>
        
        <guid>https://www.knightli.com/en/2026/04/16/vscode-docker-image-build-windows/</guid>
        <description>&lt;p&gt;If you want to build Docker images directly from VS Code on Windows, the workflow is straightforward. You only need three parts: prepare the environment, create a Dockerfile, then run the build.&lt;/p&gt;
&lt;h2 id=&#34;01-prerequisites&#34;&gt;01 Prerequisites
&lt;/h2&gt;&lt;p&gt;Make sure these two items are ready:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install and run Docker Desktop.&lt;/li&gt;
&lt;li&gt;Install the official Microsoft &lt;code&gt;Docker&lt;/code&gt; extension in VS Code.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;On Windows, using the &lt;code&gt;WSL 2&lt;/code&gt; backend in Docker Desktop (&lt;code&gt;Settings &amp;gt; Resources &amp;gt; WSL Integration&lt;/code&gt;) is usually more stable and faster.&lt;/p&gt;
&lt;h2 id=&#34;02-prepare-a-dockerfile&#34;&gt;02 Prepare a Dockerfile
&lt;/h2&gt;&lt;p&gt;If your project does not have one yet, VS Code can generate it:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open your project folder in VS Code.&lt;/li&gt;
&lt;li&gt;Press &lt;code&gt;F1&lt;/code&gt; or &lt;code&gt;Ctrl+Shift+P&lt;/code&gt; to open the Command Palette.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;Docker: Add Docker Files to Workspace&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Choose your platform (Node.js, Python, .NET, etc.) and follow the prompts.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You will typically get at least:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Dockerfile&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.dockerignore&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This gives you a working baseline that you can refine later.&lt;/p&gt;
&lt;h2 id=&#34;03-three-ways-to-build-the-image&#34;&gt;03 Three Ways to Build the Image
&lt;/h2&gt;&lt;h3 id=&#34;method-a-right-click-dockerfile&#34;&gt;Method A: Right-click Dockerfile
&lt;/h3&gt;&lt;p&gt;In the File Explorer, right-click &lt;code&gt;Dockerfile&lt;/code&gt;, select &lt;code&gt;Build Image...&lt;/code&gt;, and enter an image tag.&lt;/p&gt;
&lt;h3 id=&#34;method-b-command-palette&#34;&gt;Method B: Command Palette
&lt;/h3&gt;&lt;p&gt;Press &lt;code&gt;F1&lt;/code&gt;, run &lt;code&gt;Docker: Build Image&lt;/code&gt;, then select context and tag.&lt;/p&gt;
&lt;h3 id=&#34;method-c-integrated-terminal&#34;&gt;Method C: Integrated Terminal
&lt;/h3&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;docker build -t your-image-name .
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;This command builds an image from the current directory context with the tag &lt;code&gt;your-image-name&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;04-quick-checks-for-common-issues&#34;&gt;04 Quick Checks for Common Issues
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Docker Desktop is not running: verify it is started.&lt;/li&gt;
&lt;li&gt;Build is very slow: check whether WSL 2 backend is enabled.&lt;/li&gt;
&lt;li&gt;Build cannot find files: ensure your terminal is at the project root and files are inside build context.&lt;/li&gt;
&lt;li&gt;Docker resources do not show in VS Code: restart VS Code and check Docker CLI (&lt;code&gt;docker version&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary
&lt;/h2&gt;&lt;p&gt;Building Docker images in VS Code on Windows is mostly a setup problem. Once Docker Desktop and the VS Code Docker extension are in place, you can generate Docker files quickly and build images from either the UI or the terminal.&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
