せっかくのオンプレミスなのでxrdpで接続できるようにし、文字化けを直したAmazon Linux 2。
shigeo-t.hatenablog.com
shigeo-t.hatenablog.com
shigeo-t.hatenablog.com
shigeo-t.hatenablog.com
最終目的はDockerのコンテナに直接アクセス。長いタイトルだけど実際には『Amazon Linux 2にChroniumをインストールしChromeをインストールしVS CodeをインストールしDockerのコンテナに直接アクセス』である。
AWSの技術ドキュメント通りChroniumインストール
そんな都合のよいドキュメントがこちら。
aws.amazon.com
sudo amazon-linux-extras install epel
sudo yum install chromium
インストールされた。
![f:id:shigeo-t:20201026141544p:plain f:id:shigeo-t:20201026141544p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026141544.png)
wgetで持ってくれば済むのに、それが面倒で上記でインストールしたChronium。Chromeのトップページにアクセス。
![f:id:shigeo-t:20201026141639p:plain f:id:shigeo-t:20201026141639p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026141639.png)
ダウンロードページに飛ぶ。
![f:id:shigeo-t:20201026141725p:plain f:id:shigeo-t:20201026141725p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026141725.png)
間違ってデフォルトのdebファイルもダウンロードしたけど、rpmファイルをダウンロード。
![f:id:shigeo-t:20201026141855p:plain f:id:shigeo-t:20201026141855p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026141855.png)
手順はこちら。
optimal-sdw.com
rpmファイルをインストールする。
インストールできた。
![f:id:shigeo-t:20201026142953p:plain f:id:shigeo-t:20201026142953p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026142953.png)
VS Codeのサイトにアクセス。今度は間違えずrpmファイルをダウンロード。
![f:id:shigeo-t:20201026143157p:plain f:id:shigeo-t:20201026143157p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026143157.png)
インストールのコマンドはこちら。
code.visualstudio.com
インストールできた。
[ec2-user@amazonlinux2 Downloads]$ yum check-update
読み込んだプラグイン:langpacks, priorities, update-motd
amzn2-core | 3.7 kB 00:00
code | 3.0 kB 00:00
(1/2): code/primary_db | 490 kB 00:00
275 packages excluded due to repository priority protections
[ec2-user@amazonlinux2 Downloads]$ sudo yum install code
読み込んだプラグイン:langpacks, priorities, update-motd
amzn2-core | 3.7 kB 00:00
code | 3.0 kB 00:00
(1/2): code/primary_db | 490 kB 00:00
275 packages excluded due to repository priority protections
依存性の解決をしています
---> パッケージ code.x86_64 0:1.50.1-1602601064.el7 を インストール
--> 依存性の処理をしています: libgdk-x11-2.0.so.0()(64bit) のパッケージ: code-1.50.1-1602601064.el7.x86_64
---> パッケージ gtk2.x86_64 0:2.24.31-1.amzn2.0.2 を インストール
--> 依存性解決を終了しました。
依存性を解決しました
================================================================================
================================================================================
インストール中:
code x86_64 1.50.1-1602601064.el7 code 89 M
依存性関連でのインストールをします:
gtk2 x86_64 2.24.31-1.amzn2.0.2 amzn2-core 3.4 M
================================================================================
インストール 1 パッケージ (+1 個の依存関係のパッケージ)
総ダウンロード容量: 92 M
インストール容量: 274 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): gtk2-2.24.31-1.amzn2.0.2.x86_64.rpm | 3.4 MB 00:00
(2/2): code-1.50.1-1602601064.el7.x86_64.rpm | 89 MB 00:09
--------------------------------------------------------------------------------
合計 10 MB/s | 92 MB 00:09
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告: RPMDB は yum 以外で変更されました。
インストール中 : gtk2-2.24.31-1.amzn2.0.2.x86_64 1/2
インストール中 : code-1.50.1-1602601064.el7.x86_64 2/2
検証中 : gtk2-2.24.31-1.amzn2.0.2.x86_64 1/2
検証中 : code-1.50.1-1602601064.el7.x86_64 2/2
インストール:
code.x86_64 0:1.50.1-1602601064.el7
依存性関連をインストールしました:
gtk2.x86_64 0:2.24.31-1.amzn2.0.2
完了しました!
VS Codeが追加されている。
![f:id:shigeo-t:20201026143720p:plain f:id:shigeo-t:20201026143720p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026143720.png)
拡張機能を追加してDockerのコンテナに直接アクセス
起動してまず日本語化。
![f:id:shigeo-t:20201026143840p:plain f:id:shigeo-t:20201026143840p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026143840.png)
続いてDocker関係とssh関係の拡張機能をインストール。
![f:id:shigeo-t:20201026144031p:plain f:id:shigeo-t:20201026144031p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026144031.png)
インストールした拡張機能はこちら。全てMicrosoft謹製。
![f:id:shigeo-t:20201027033823p:plain f:id:shigeo-t:20201027033823p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201027/20201027033823.png)
接続してみる。
![f:id:shigeo-t:20201026144436p:plain f:id:shigeo-t:20201026144436p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026144436.png)
右クリックするとこのようなメニューが出る。
![f:id:shigeo-t:20201026144523p:plain f:id:shigeo-t:20201026144523p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026144523.png)
Attach Shellを選ぶとこのようにターミナルが現れる。
![f:id:shigeo-t:20201026144611p:plain f:id:shigeo-t:20201026144611p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026144611.png)
![f:id:shigeo-t:20201027034808p:plain f:id:shigeo-t:20201027034808p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201027/20201027034808.png)
左下の><アイコンをクリックするとこのプルダウンメニューが表示される。[Remote-Containers:Attach to Running Container…]をクリックする。
![f:id:shigeo-t:20201026144753p:plain f:id:shigeo-t:20201026144753p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026144753.png)
接続したい方を選びEnterを押す。
![f:id:shigeo-t:20201026144828p:plain f:id:shigeo-t:20201026144828p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026144828.png)
別ウィンドウでつながった。
![f:id:shigeo-t:20201026144920p:plain f:id:shigeo-t:20201026144920p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026144920.png)
![f:id:shigeo-t:20201026144953p:plain f:id:shigeo-t:20201026144953p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026144953.png)
アクセス先フォルダーを選択する。
![f:id:shigeo-t:20201026145320p:plain f:id:shigeo-t:20201026145320p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026145320.png)
とりあえず/etcを選ぶ。
![f:id:shigeo-t:20201026145148p:plain f:id:shigeo-t:20201026145148p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026145148.png)
inittabを開いて見る。
![f:id:shigeo-t:20201026145449p:plain f:id:shigeo-t:20201026145449p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/s/shigeo-t/20201026/20201026145449.png)
ということでdocker exec -it bashなしでもターミナルは開くし、ターミナルでviを使わなくても編集できる。Windows側のVS Codeを使うよりも便利である。AWS上でこういう環境を作ることはまあ無いと思うけど、オンプレミスの開発環境ならいいだろう。