Closed5
WSL2 × Docker × VSCodeで開発環境を作る
![wattanx](https://res.cloudinary.com/zenn/image/fetch/s--3x_5yWjs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/53fb48bf74.jpeg)
はじめに
WSL2を使うことで今までWindows 10 Proでしか使えなかったDocker DesctopがWindows Homeでも使えるので環境を作成してみる。
![wattanx](https://res.cloudinary.com/zenn/image/fetch/s--3x_5yWjs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/53fb48bf74.jpeg)
WSL2のインストール
以下公式手順通りにインストール
![wattanx](https://res.cloudinary.com/zenn/image/fetch/s--3x_5yWjs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/53fb48bf74.jpeg)
VSCodeの拡張機能を入れる
Remote Development
を入れる。
![wattanx](https://res.cloudinary.com/zenn/image/fetch/s--3x_5yWjs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/53fb48bf74.jpeg)
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"
![wattanx](https://res.cloudinary.com/zenn/image/fetch/s--3x_5yWjs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/53fb48bf74.jpeg)
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にクローズされました