Closed5
WSL2 × Docker × VSCodeで開発環境を作る

はじめに
WSL2を使うことで今までWindows 10 Proでしか使えなかったDocker DesctopがWindows Homeでも使えるので環境を作成してみる。

WSL2のインストール
以下公式手順通りにインストール

VSCodeの拡張機能を入れる
Remote Development
を入れる。

Dockerfile、docker-compose.ymlを作成
Dockerfile
FROM node:14
docker-compose.yml
version: "3"
services:
app:
build: .
ports:
- 3000:3000
volumes:
- ..:/workspace:cached
command: /bin/sh -c "while sleep 1000; do :; done"

devcontainer.jsonを作成
/.devcontainer/devcontainer.json
{
"name": "test",
"dockerComposeFile": [
"docker-compose.yml"
],
"service": "app",
"workspaceFolder": "/workspace",
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
このスクラップは2021/05/15にクローズされました