LoginSignup
0
0

More than 1 year has passed since last update.

DevcontainerでPython環境構築

Last updated at Posted at 2022-08-13

前提

このエントリーは、VSCodeを利用してPython関連の開発をする際に、Devcontainerを利用する方法を記します。

事前の準備

以下の準備は終わっているものとします。

  • VSCodeのインストール
  • VSCodeの日本語化
  • docker 及び docker-compose のインストール

利用環境

私の環境はLinux(Ubuntu 20.04)とmacOS(12.5)を利用しています。

拡張機能

  • VSCodeの拡張機能 Remote - Contaiers (Microsoft社製) をインストール

開発環境ごとの設定

  • Ctrl + Shift + p でコマンドパレットを開く
  • Remote-Containers: Add Development Container Configuration Files... を選択
  • Python 3 を選択
  • 3.10-bullseye を選択(必要なバージョンに合わせる)
  • Nodeバージョン lts/*
  • その他のツールを選択(私はほとんどの場合以下を選択)
    • Git
    • Jupyter Lab

ファイル構成

  • .devcontainer フォルダが作成
  • devcontainer.json と Dockerfile ファイルが作成

起動

コマンドパレット(Ctrl+Shift+P)から

  • Remote-Containers: Reopen remote Container
  • Docker Image をPullしてビルドするのでそれなりに時間がかかる

停止

コマンドパレット(Ctrl+Shift+P)から

  • Remote-Containers: Reopen folder locally を実行

再利用

コマンドパレット(Ctrl+Shift+P)から

  • Remote-Containers: Reopen in Container を実行
0
0
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
0
0