LXC:WSL上でLXCを実行してみる


WSL上でLXCを実行してみる

第1回 LXCとコンテナの基本 | gihyo.jp

LXC:LinuX Containerの略で、linuxcontainers.org で開発されているコンテナを扱うためのソフトウェア、というやつらしい。
WSL上でLXCが動くのか試してみた。

1. インストール
sudo apt-get install lxc

2. コンテナ環境の作成
sudo lxc-create -t ubuntu -n ubuntu01
"-t ubuntu" - template指定。Ubuntuのテンプレートを使ってコンテナを作る
"-n ubuntu01" - コンテナ名を ubuntu01 にする

3. コンテナを起動
sudo lxc-start -n ubuntu01 -d
"-n ubuntu01" - ubuntu01 という名前のコンテナを指定
"-d" - detached mode(バックグラウンド起動)
コマンド実行しても特に何も起こらない

4. 起動確認
LCXコンテナの一覧を表示
sudo lxc-ls --fancy
"--fancy" - 詳細表示

実行結果:
xxx@hppc:~$ sudo lxc-ls --fancy
NAME     STATE   AUTOSTART GROUPS IPV4       IPV6 UNPRIVILEGED
ubuntu01 RUNNING 0         -      10.0.3.186 -    false      
    
STATEが"RUNNING"ということでコンテナは起動している

5. コンテナに接続
lxc-createコマンドで"-t ubuntu"でUbuntuコンテナを作成した場合、デフォルトで"ubuntu"ユーザー(ubuntu)が作成される
sudo lxc-console -n ubuntu01
"-n ubuntu01" - ubuntu01 という名前のコンテナを指定

コマンド実行すると "ubuntu01 login:"となるので "ubuntu"、パスワード"ubuntu"でログインする。
コンソールから抜けるには [CTRL]+[a] を押した後に [q] を入力する。

6. コンテナの終了
コンテナを終了するにはコンソールにログインした状態で "sudo shutdown" コマンドを実行、または
コンソールの外で "sudo lxc-stop -n ubuntu01" を実行する。


LXC, WSL

Docker:WSL:一般ユーザーでDockerコマンドを使う


WSL上のDocker環境でのDockerコマンドを一般ユーザーで使えるようにする

WSLでDockerコマンドを使う際、毎回 "sudo docker…" とするのが面倒なので、
一般ユーザーでもDockerコマンドが実行できるように設定する。

dockerグループに操作者ユーザーを追加すればよい。
sudo usermod -aG docker $USER

いちどログインし直さないとダメみたいなので "logout"コマンド実行してからUbuntuコマンドを起動すればOK


Docker, WSL

Python:WindowsにPython環境を作る


WindowsにPython環境を作る

WindowsにPython環境を作る、どうやれば良い?

Microsoft Storeから「python」で検索、
現時点では3つ候補が出てくる。
・Python 3.13
・Python 3.12
・Python Install Manager

Python 3.13、3.12は何となくわかるが、Python Install Managerって何者?
以下記事によると、Python Install Managerを使うことが推薦、とのこと。
Windows版のPythonのインストール方法が大きく変わる Python Install Managerが登場

Python Install Managerを使うと複数のバージョンのPytyonを管理できるっぽい。

ということでMicrosoft Storeより「Pytyon Install Manager」をインストールした。
途中でWindows Terminalが開き何やら処理が始まるが・・
どうやら旧バージョンのPython(pyコマンド)を入れてたらしい。
Welcome to the Python installation manager configuration helper.

********************************************************************************

Windows is not configured to allow paths longer than 260 characters.

Python and some other apps can exceed this limit, but it requires changing a
system-wide setting, which may need an administrator to approve, and will
require a reboot. Some packages may fail to install without long path support
enabled.
Update setting now? [y/N] y
The setting has been successfully updated, and will take effect after the next reboot.

********************************************************************************

The legacy 'py' command is still installed.

This may interfere with launching the new 'py' command, and may be resolved by
uninstalling 'Python launcher'.
Open Installed apps now? [y/N]    
  
[y]を入力しインストールされているアプリ一覧画面を開いたら
・Python 3.12.3(64-bit)
・Python Launcher
を2024年ごろにインストールしてたっぽいのでアンインストール


これで良いのかわからないが先進める。
Configuring this enables commands like python3.14.exe to run from your
terminal, but is not needed for the python or py commands (for example, py
-V:3.14).

We can add the directory (C:\Users\masat\AppData\Local\Python\bin) to PATH now,
but you will need to restart your terminal to use it. The entry will be removed
if you run py uninstall --purge, or else you can remove it manually when
uninstalling Python.
Add commands directory to your PATH now? [y/N]  
とりあえず [y] でパスには追加。
You do not have the latest Python runtime.

Install the current latest version of CPython? If not, you can use 'py install
default' later to install.

Install CPython now? [Y/n]    
  
最新のPytyonがインストールされていないのでCPythonをインストールするか?だと。
CPytyonって何?
Python = CPython (C言語で記述したPytyon) っぽい。なので[y]でインストールする。

次にオンラインヘルプを表示するか聞いてきた。いらないので[N]
View online help? [y/N]    
  
これでインストールできた?


Python

その他の記事