1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DevcontainerをCLIで起動・アタッチする方法

Posted at

devcontainerのcliを利用します。

インストール

nvmでnodejsをインストールする

# 最新のltsをインストール
nvm install --lts
nvm use --lts

# デフォルトに設定
nvm alias default lts/jod

devcontainers/cli をインストール

# devcontainers/cliをインストール
npm install -g @devcontainers/cli

CLIでdevcontainerをビルド

# devcontainerのリビルド
# path/to/projectには.devcontainerディレクトリが存在するパスを指定
devcontainer build --workspace-folder path/to/project

CLIでdevcontainerを起動

# プロジェクトに入ってdevcontainerを起動・アタッチ
# path/to/projectには.devcontainerディレクトリが存在するパスを指定
devcontainer up --workspace-folder path/to/project

# devcontainerにログイン
devcontainer exec --workspace-folder path/to/project /bin/bash

CLIでdevcontainerを削除

# devcontainerのコンテナIDを特定
docker ps
# CONTAINER ID   IMAGE                                                                                              COMMAND                  CREATED        STATUS       PORTS     NAMES
# 631ee8b210a8   vsc-eks-hybrid-nodes-sample-46d317f27912914a79fc924e8a49d6383bb6fff2dbbe5522cd9eac2ddb239a45-uid   "/bin/sh -c 'echo Co…"   39 hours ago   Up 5 hours             competent_gauss

# コンテナを削除
docker rm -f 631ee8b210a8
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?