Build a Docker-based development environment on Windows 10 Home 2020 ver. Part 2 VS Code should make the Docker development environment comfortable

Introduction

Last time, I built Docker that seems to work properly on Windows 10 Home. This time, we will set VS Code that seems to be fully usable as an integrated development environment.

Let's define a comfortable development environment

(I regret that it should be written in Part 1) When I think about why Windows-based and uncomfortable development occurs in the first place, I think the main reason is that Windows does not work as well as Linux and Unix (Mac). I thought about improvement points and improvement methods.

  1. Modules required for development such as ruby, python, MySQL do not work properly (I feel) → WSL2-based Docker works properly (should)
  2. Version control of modules required for development is already chaos (this is the same for Mac) → Docker Prepare an appropriate environment as a container. However, it is possible to switch to that environment immediately.
  3. I'm not used to operating terminals such as command prompt and PowerShell. Bash is good → Introducing bash that runs on Windows

Since 1 introduced Docker Desktop, I will just touch it, but I will solve it for the time being. The rest are 2 and 3.

Version control of modules required for development

It's up to Docker to prepare the container environment, and the problem is that you can quickly switch to that development environment. More specifically, the container environment is used as the development environment. I investigated whether it could be moved properly. Remote Development of VSCode looks good, so I built it. 「Visual Studio Code Remote Development allows you to use a container」 https://code.visualstudio.com/docs/remote/remote-overview

VSCode & Remote Containers Install VS Code. https://azure.microsoft.com/ja-jp/products/visual-studio-code/

Install the extension Remote Containers https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers image.png

This will add a new green status bar at the bottom left of VS Code. Click it and you will see the Remote Containers command. image.png

Since there is no development environment at the moment, I will introduce the Python Sample development environment. Select Remote-Containers: Try a Sample ... and click Python in it image.png The container has begun to be installed. image.png

The sample Python development environment is now ready. It took only a few minutes. It's comfortable. image.png

The new container is also recognized on the Docker Desktop screen. image.png

Go back to VS Code and press F5 to launch a web application using the sample Flask. Mouse over the URL that follows Running on and click Follow Link. image.png

If the web browser starts up and you see the screen below, you are successful. image.png

Finally, what you can develop ≒ Let's edit the code on VS Code. Open index.html, add the Japanese word "Of course you can do it!" And save it. image.png

When you reload your web browser ... image.png

The code was reflected as intended. The rest is git, but I have not installed it in Windows yet, but since it is installed in the container, it can be executed from VS Code. However, git settings on the container side are required. It is not comfortable to set git on the container side every time. VSCode Remote Containers allows you to share git information on the local side. Let's install git locally.

Install Git for Windows

Download the installer from the official website. https://git-scm.com/download/win

Basically, if you follow the wizard, there is no problem, but there are some parts that you should consider changing.

Set to VS Code by selecting the default editor

(I think Vim is fine)) image.png

Set line feed code conversion to "Check out as-is, commit Unix-style line ending"

If the development environment is Windows and the execution environment is Linux, it is recommended to use this. (Checkout Windows-style changes the line feed code to CRLF at checkout. If you want to use an editor that only supports Windows line feed code, such as the previous notepad, select this, but I think that there are few such people now)

After installation, launch Git Bash and set user.name and user.email with the following command

> git config --global user.name "TakaK"
> git config --global user.email "[email protected]"

This is OK for the git settings for the time being.

Reflect git settings in existing container

The git settings are automatically copied and reflected when the container is built, so you need to rebuild to reflect them in the existing container.

image.png

After that, you can work with normal git commands or git UI on VS Code as you like.

In the future, it will be necessary to set up a remote repository, but I think that development itself using containers locally can be done.

Recommended Posts

Build a Docker-based development environment on Windows 10 Home 2020 ver. Part 2 VS Code should make the Docker development environment comfortable
Build a Doker-based development environment on Windows 10 Home 2020 ver. Part 1 Until WSL2-based Docker build
Building a haskell environment with Docker + VS Code on Windows 10 Home
Build a Java development environment with VS Code
Build Java development environment with VS Code on Mac
Build Java development environment with WSL2 Docker VS Code
[Environment construction] Build a Java development environment with VS Code!
Install Ubuntu 20.04 in virtual box on windows10 and build a development environment using docker
Until you build a Nuxt.js development environment with Docker and touch it with VS Code
A memo when building a Rails 5.2 development environment using Docker Desktop + WSL2 on Windows 10 Home
Build Unity development environment on docker
Build a development environment where Ruby on Rails breakpoints work on Windows
Build a browser test environment using Capybara in the Docker development environment
[Be careful about changing the version of Xdebug! ] Create a development environment with Xdebug3 + docker + VS Code
Build a PureScript development environment with Docker
Build a Java development environment on Mac
Build a Wordpress development environment with Docker
Build Redmine code reading environment on Docker
Build an Ultra96v2 development environment on Docker 1
Build a simple Docker + Django development environment
[Copy and paste] Build a Laravel development environment with Docker Compose Part 2
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Build a development environment for Docker + Rails6 + Postgresql
Connect with VS Code from a Windows client to Docker on another server
Build a WordPress development environment quickly with Docker
Build a simple Docker Compose + Django development environment
Build a development environment to create Ruby on Jets + React apps with Docker
Build a development environment for Docker, java, vscode
Build a Ruby on Rails development environment on AWS Cloud9
Docker the development environment of Ruby on Rails project
Build ruby debug environment with VS Code of Windows 10
How to build Java development environment with VS Code
Try to build a Java development environment using Docker
Make the strongest Laravel development environment (Docker) Japan time
One file of Docker x Laravel threat! Build a local development environment with the minimum configuration
Try Docker on Windows 10 Home
Ruby ① Build a Windows environment
Build an ASP.net Core Web API environment on Docker (VSCode) Part 1
Build an ASP.NET Core Web API environment on Docker (VSCode) Part 2
Build a development environment for Django + MySQL + nginx with Docker Compose
Steps to build a Ruby on Rails development environment with Vagrant
We will build a Spring Framework development environment in the on-premises environment.
Build a web application development environment that uses Java, MySQL, and Redis with Docker CE for Windows
Build a Node.js environment with Docker
Use Docker Compose on Windows 10 Home
Build a XAMPP environment on Ubuntu
Try Docker on Windows Home (September 2020)
Java development environment (Mac, VS Code)
Using Docker on Windows10 Home WSL2
Build debug environment on container --Build local development environment for Rails tutorial with Docker-
Let's install Docker on Windows 10 and create a verification environment for CentOS 8!
Make a daily build of the TOPPERS kernel with Gitlab and Docker
How to build a Ruby on Rails environment using Docker (for Docker beginners)
Creating a java web application development environment with docker for mac part1
I tried to build a Firebase application development environment with Docker in 2020
A memo that enabled VS Code + JUnit 5 to be used on Windows 10
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
[Docker] How to build when the source code is bind-mounted on the container
[Copy and paste] Build a Laravel development environment with Docker Compose Participation
Build a development environment on AWS EC2 with CentOS7 + Nginx + pm2 + Nuxt.js