いろいろ備忘録日記

主に .NET とか Go とか Flutter とか Python絡みのメモを公開しています。

Gitpod に Feature Preview 機能が追加 (rootアクセス, Docker使用, IDE選べる)

概要

Gitpodに Feature Preview の機能が追加されたので、メモメモ。

www.gitpod.io

www.gitpod.io

rootアクセスが出来るようになるのと docker 使えるようになるのが素晴らしいですね。これは便利になります。

利用するには、予め Gitpod にログインして Settings のところから Enable Feature Preview を ON にしておく必要があります。

こんな感じ。

f:id:gsf_zero1:20201211115500p:plain

ただし、上の Feature Preview のページにも以下のように記載されています

Once you enable this, existing and new workspaces will automatically start with all beta features. Disabling this could make existing workspaces unstable.

このリスクを理解してからONにしましょう。

試してみる

root アクセス

ちょっと試してみました。

まずは root アクセス。

以前のGitpodでは、.gitpod.Dockerfile 以外では sudo が実行できませんでしたが、Feature PreviewをONにしたコンテナだと実行できるようになります。

gitpod /workspace/gitpod-playground $ mc
bash: mc: command not found

gitpod /workspace/gitpod-playground $ sudo apt install mc
sudo: setrlimit(RLIMIT_CORE): Operation not permitted
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libicu65
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libslang2 libssh2-1 mc-data
Suggested packages:
  arj catdvi | texlive-binaries dbview djvulibre-bin epub-utils genisoimage gv libaspell-dev links | w3m | lynx odt2txt poppler-utils python python-boto python-tz xpdf | pdf-viewer
The following NEW packages will be installed:
  libslang2 libssh2-1 mc mc-data
0 upgraded, 4 newly installed, 0 to remove and 133 not upgraded.
Need to get 2,246 kB of archives.
After this operation, 9,657 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libslang2 amd64 2.3.2-4 [429 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 libssh2-1 amd64 1.8.0-2.1build1 [75.4 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/universe amd64 mc-data all 3:4.8.24-2ubuntu1 [1,265 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal/universe amd64 mc amd64 3:4.8.24-2ubuntu1 [477 kB]
Fetched 2,246 kB in 1s (1,521 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libslang2:amd64.
(Reading database ... 33869 files and directories currently installed.)
Preparing to unpack .../libslang2_2.3.2-4_amd64.deb ...
Unpacking libslang2:amd64 (2.3.2-4) ...
Selecting previously unselected package libssh2-1:amd64.
Preparing to unpack .../libssh2-1_1.8.0-2.1build1_amd64.deb ...
Unpacking libssh2-1:amd64 (1.8.0-2.1build1) ...
Selecting previously unselected package mc-data.
Preparing to unpack .../mc-data_3%3a4.8.24-2ubuntu1_all.deb ...
Unpacking mc-data (3:4.8.24-2ubuntu1) ...
Selecting previously unselected package mc.
Preparing to unpack .../mc_3%3a4.8.24-2ubuntu1_amd64.deb ...
Unpacking mc (3:4.8.24-2ubuntu1) ...
Setting up libslang2:amd64 (2.3.2-4) ...
Setting up mc-data (3:4.8.24-2ubuntu1) ...
Setting up libssh2-1:amd64 (1.8.0-2.1build1) ...
Setting up mc (3:4.8.24-2ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for libc-bin (2.31-0ubuntu7) ...

インストールできちゃいました。素晴らしい。

このあとで

$ mc

ってやると、ちゃんと midnight commander が起動します。

docker

dockerも使えるようになっています。試してみましょう。

まず、dockerデーモンを起動する必要があります。

gitpod /workspace/gitpod-playground $ sudo docker-up 
sudo: setrlimit(RLIMIT_CORE): Operation not permitted
WARN[0000] missing prerequisite                          command=dockerd service=runOutsideNetns
WARN[0000] missing prerequisite                          command=slirp4netns service=runOutsideNetns
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libicu65
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  apparmor bridge-utils cgroupfs-mount containerd dns-root-data dnsmasq-base iptables libidn11 libip6tc2 libnetfilter-conntrack3 libnfnetlink0 libnftnl11 netcat netcat-openbsd pigz runc ubuntu-fan
Suggested packages:
  apparmor-profiles-extra apparmor-utils ifupdown aufs-tools btrfs-progs debootstrap docker-doc rinse zfs-fuse | zfsutils firewalld kmod nftables
The following NEW packages will be installed:
  apparmor bridge-utils cgroupfs-mount containerd dns-root-data dnsmasq-base docker.io iptables libidn11 libip6tc2 libnetfilter-conntrack3 libnfnetlink0 libnftnl11 netcat netcat-openbsd pigz runc slirp4netns ubuntu-fan
0 upgraded, 19 newly installed, 0 to remove and 133 not upgraded.
Need to get 70.8 MB of archives.
After this operation, 340 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 pigz amd64 2.4-1 [57.4 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 netcat-openbsd amd64 1.206-1ubuntu1 [37.8 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/main amd64 apparmor amd64 2.13.3-7ubuntu5 [494 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal/main amd64 libip6tc2 amd64 1.8.4-3ubuntu2 [19.2 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal/main amd64 libnfnetlink0 amd64 1.0.1-3build1 [13.8 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/main amd64 libnetfilter-conntrack3 amd64 1.0.7-2 [41.4 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/main amd64 libnftnl11 amd64 1.1.5-1 [57.8 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 iptables amd64 1.8.4-3ubuntu2 [390 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal/main amd64 bridge-utils amd64 1.6-2ubuntu1 [30.5 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal/universe amd64 cgroupfs-mount all 1.4 [6,320 B]
Get:11 http://archive.ubuntu.com/ubuntu focal/main amd64 runc amd64 1.0.0~rc10-0ubuntu1 [2,549 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal/main amd64 containerd amd64 1.3.3-0ubuntu2 [27.8 MB]
Get:13 http://archive.ubuntu.com/ubuntu focal/main amd64 dns-root-data all 2019052802 [5,300 B]
Get:14 http://archive.ubuntu.com/ubuntu focal/main amd64 libidn11 amd64 1.33-2.2ubuntu2 [46.2 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal/main amd64 dnsmasq-base amd64 2.80-1.1ubuntu1 [314 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal/universe amd64 docker.io amd64 19.03.8-0ubuntu1 [38.9 MB]
Get:17 http://archive.ubuntu.com/ubuntu focal/universe amd64 netcat all 1.206-1ubuntu1 [2,172 B]
Get:18 http://archive.ubuntu.com/ubuntu focal/universe amd64 slirp4netns amd64 0.4.3-1 [74.3 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal/main amd64 ubuntu-fan all 0.12.13 [34.5 kB]
・
・
割愛
・
・
INFO[2020-12-11T04:01:46.746014627Z] Docker daemon                                 commit=afacb8b7f0 graphdriver(s)=vfs version=19.03.8
INFO[2020-12-11T04:01:46.746229720Z] Daemon has completed initialization          
INFO[2020-12-11T04:01:46.769396766Z] API listen on /var/run/docker.sock

起動したら、新しいターミナルでdockerが使えます。

gitpod /workspace/gitpod-playground $ docker -v
Docker version 19.03.8, build afacb8b7f0

gitpod /workspace/gitpod-playground $ go version
go version go1.15 linux/amd64

gitpod /workspace/gitpod-playground $ docker run -it --rm golang:latest
Unable to find image 'golang:latest' locally
latest: Pulling from library/golang
756975cb9c7e: Pull complete 
d77915b4e630: Pull complete 
5f37a0a41b6b: Pull complete 
96b2c1e36db5: Pull complete 
145393847161: Pull complete 
3f8843661db9: Pull complete 
218d240e42d4: Pull complete 
Digest: sha256:0dbb6056947855e8c1b1fb69d1b27f7cd004a48d821471e1a7e2731437879d44
Status: Downloaded newer image for golang:latest

root@b96c67f4e0d3:/go# go version
go version go1.15.6 linux/amd64

いやー、超便利。

参考情報

www.gitpod.io

www.gitpod.io


過去の記事については、以下のページからご参照下さい。

  • いろいろ備忘録日記まとめ

devlights.github.io

サンプルコードは、以下の場所で公開しています。

  • いろいろ備忘録日記サンプルソース置き場

github.com

github.com

github.com