docker Advent Calendar 2021 10日目の記事の紹介です。
https://qiita.com/advent-calendar/2021/docker
ご投稿ありがとうございます。
@blueskyarea Docker ホスト-コンテナ間でのユーザー/グループの分離をしたい
https://qiita.com/blueskyarea/items/7453c5782bbc16b00415
Linux上でdocker上のLinuxを動かす場合の、利用者(user)管理によるファイル管理を試されています。
現在、macOSで作業をしており、追試はできていません。ごめんなさい。
自分が興味を持ったとこだけ、おまけとして記録させてください。
記事の一番肝心な技術については、何かの機会に試させてください。
macOSのuser、Winoowsのuserとの関係の調査はいつかしてみようと思いました。
記事に関連して
dockerを使っている時に、よくやる操作誤りは、どちら側で操作しているかを忘れてしまうことです。
この記事のように、コマンドプロンプトが違うから、そんなに間違えないよという方もおみえでしょう。
私はしょっ中やらかします。
今は、macOSで操作しているから apt ってやっても動かないのでいいのですが、
ubuntu にbrewを入れてしまったら、やらかすかもしれません。
記事には、どちら側の操作かを示していただいているので安心です。
user
補足1に書かれていることの関連事項です。
Linuxの利用者(user)管理ではいろいろ痛い目にあっています。
コマンドによる利用者の追加と、設定ファイルの同期をうまく取らないと、zombie(活動死体)かghost(幽霊)になるかもしれない。
ある配布(distribution)のある版(version)では、複数のコマンドが存在しており、振る舞いが少し違うことがあったりした。
その配布のその版で、一番お勧めな方法以外は取らないようにしている。
現在のdocker上のubuntuでコマンドを見た。
# useradd
Usage: useradd [options] LOGIN
useradd -D
useradd -D [options]
Options:
--badnames do not check for bad names
-b, --base-dir BASE_DIR base directory for the home directory of the
new account
--btrfs-subvolume-home use BTRFS subvolume for home directory
-c, --comment COMMENT GECOS field of the new account
-d, --home-dir HOME_DIR home directory of the new account
-D, --defaults print or change default useradd configuration
-e, --expiredate EXPIRE_DATE expiration date of the new account
-f, --inactive INACTIVE password inactivity period of the new account
-g, --gid GROUP name or ID of the primary group of the new
account
-G, --groups GROUPS list of supplementary groups of the new
account
-h, --help display this help message and exit
-k, --skel SKEL_DIR use this alternative skeleton directory
-K, --key KEY=VALUE override /etc/login.defs defaults
-l, --no-log-init do not add the user to the lastlog and
faillog databases
-m, --create-home create the user's home directory
-M, --no-create-home do not create the user's home directory
-N, --no-user-group do not create a group with the same name as
the user
-o, --non-unique allow to create users with duplicate
(non-unique) UID
-p, --password PASSWORD encrypted password of the new account
-r, --system create a system account
-R, --root CHROOT_DIR directory to chroot into
-P, --prefix PREFIX_DIR prefix directory where are located the /etc/* files
-s, --shell SHELL login shell of the new account
-u, --uid UID user ID of the new account
-U, --user-group create a group with the same name as the user
-Z, --selinux-user SEUSER use a specific SEUSER for the SELinux user mapping
--extrausers Use the extra users database
# adduser -h
adduser [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID]
[--firstuid ID] [--lastuid ID] [--gecos GECOS] [--ingroup GROUP | --gid ID]
[--disabled-password] [--disabled-login] [--add_extra_groups]
[--encrypt-home] USER
Add a normal user
adduser --system [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID]
[--gecos GECOS] [--group | --ingroup GROUP | --gid ID] [--disabled-password]
[--disabled-login] [--add_extra_groups] USER
Add a system user
adduser --group [--gid ID] GROUP
addgroup [--gid ID] GROUP
Add a user group
addgroup --system [--gid ID] GROUP
Add a system group
adduser USER GROUP
Add an existing user to an existing group
general options:
--quiet | -q don't give process information to stdout
--force-badname allow usernames which do not match the
NAME_REGEX[_SYSTEM] configuration variable
--extrausers uses extra users as the database
--help | -h usage message
--version | -v version number and copyright
--conf | -c FILE use FILE as configuration file
did
docker 内でdockerを起動する方法を探しました。
docker コマンドは導入できますが、dockerコマンドが見当たりません。
結果として、やってみたいことのやり方は見つかりませんでした。
docker上でPOSIXのTestSuiteの実行をしていないことに気がつきました。
別記事で立てようと思いました。
# docker run -it ubuntu /bin/bash
# apt update; apt -y upgrade
# apt -y install docker
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libbsd0 libglib2.0-0 libglib2.0-data libicu66 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxml2 shared-mime-info tzdata wmdocker
xdg-user-dirs
The following NEW packages will be installed:
docker libbsd0 libglib2.0-0 libglib2.0-data libicu66 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxml2 shared-mime-info tzdata
wmdocker xdg-user-dirs
0 upgraded, 15 newly installed, 0 to remove and 0 not upgraded.
Need to get 12.0 MB of archives.
After this operation, 50.5 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libbsd0 amd64 0.10.0-1 [45.4 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-0 amd64 2.64.6-1~ubuntu20.04.4 [1287 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-data all 2.64.6-1~ubuntu20.04.4 [6052 B]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 tzdata all 2021e-0ubuntu0.20.04 [295 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libicu66 amd64 66.1-2ubuntu2.1 [8515 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libxml2 amd64 2.9.10+dfsg-5ubuntu0.20.04.1 [640 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/main amd64 shared-mime-info amd64 1.15-1 [430 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 xdg-user-dirs amd64 0.17-2ubuntu1 [48.3 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal/main amd64 libxau6 amd64 1:1.0.9-0ubuntu1 [7488 B]
Get:10 http://archive.ubuntu.com/ubuntu focal/main amd64 libxdmcp6 amd64 1:1.1.3-0ubuntu1 [10.6 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal/main amd64 libxcb1 amd64 1.14-2 [44.7 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libx11-data all 2:1.6.9-2ubuntu1.2 [113 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libx11-6 amd64 2:1.6.9-2ubuntu1.2 [575 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal/universe amd64 wmdocker amd64 1.5-2 [13.0 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal/universe amd64 docker all 1.5-2 [1316 B]
Fetched 12.0 MB in 5s (2219 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libbsd0:amd64.
(Reading database ... 4127 files and directories currently installed.)
Preparing to unpack .../00-libbsd0_0.10.0-1_amd64.deb ...
Unpacking libbsd0:amd64 (0.10.0-1) ...
Selecting previously unselected package libglib2.0-0:amd64.
Preparing to unpack .../01-libglib2.0-0_2.64.6-1~ubuntu20.04.4_amd64.deb ...
Unpacking libglib2.0-0:amd64 (2.64.6-1~ubuntu20.04.4) ...
Selecting previously unselected package libglib2.0-data.
Preparing to unpack .../02-libglib2.0-data_2.64.6-1~ubuntu20.04.4_all.deb ...
Unpacking libglib2.0-data (2.64.6-1~ubuntu20.04.4) ...
Selecting previously unselected package tzdata.
Preparing to unpack .../03-tzdata_2021e-0ubuntu0.20.04_all.deb ...
Unpacking tzdata (2021e-0ubuntu0.20.04) ...
Selecting previously unselected package libicu66:amd64.
Preparing to unpack .../04-libicu66_66.1-2ubuntu2.1_amd64.deb ...
Unpacking libicu66:amd64 (66.1-2ubuntu2.1) ...
Selecting previously unselected package libxml2:amd64.
Preparing to unpack .../05-libxml2_2.9.10+dfsg-5ubuntu0.20.04.1_amd64.deb ...
Unpacking libxml2:amd64 (2.9.10+dfsg-5ubuntu0.20.04.1) ...
Selecting previously unselected package shared-mime-info.
Preparing to unpack .../06-shared-mime-info_1.15-1_amd64.deb ...
Unpacking shared-mime-info (1.15-1) ...
Selecting previously unselected package xdg-user-dirs.
Preparing to unpack .../07-xdg-user-dirs_0.17-2ubuntu1_amd64.deb ...
Unpacking xdg-user-dirs (0.17-2ubuntu1) ...
Selecting previously unselected package libxau6:amd64.
Preparing to unpack .../08-libxau6_1%3a1.0.9-0ubuntu1_amd64.deb ...
Unpacking libxau6:amd64 (1:1.0.9-0ubuntu1) ...
Selecting previously unselected package libxdmcp6:amd64.
Preparing to unpack .../09-libxdmcp6_1%3a1.1.3-0ubuntu1_amd64.deb ...
Unpacking libxdmcp6:amd64 (1:1.1.3-0ubuntu1) ...
Selecting previously unselected package libxcb1:amd64.
Preparing to unpack .../10-libxcb1_1.14-2_amd64.deb ...
Unpacking libxcb1:amd64 (1.14-2) ...
Selecting previously unselected package libx11-data.
Preparing to unpack .../11-libx11-data_2%3a1.6.9-2ubuntu1.2_all.deb ...
Unpacking libx11-data (2:1.6.9-2ubuntu1.2) ...
Selecting previously unselected package libx11-6:amd64.
Preparing to unpack .../12-libx11-6_2%3a1.6.9-2ubuntu1.2_amd64.deb ...
Unpacking libx11-6:amd64 (2:1.6.9-2ubuntu1.2) ...
Selecting previously unselected package wmdocker.
Preparing to unpack .../13-wmdocker_1.5-2_amd64.deb ...
Unpacking wmdocker (1.5-2) ...
Selecting previously unselected package docker.
Preparing to unpack .../14-docker_1.5-2_all.deb ...
Unpacking docker (1.5-2) ...
Setting up libxau6:amd64 (1:1.0.9-0ubuntu1) ...
Setting up xdg-user-dirs (0.17-2ubuntu1) ...
Setting up libglib2.0-0:amd64 (2.64.6-1~ubuntu20.04.4) ...
No schema files found: doing nothing.
Setting up tzdata (2021e-0ubuntu0.20.04) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Configuring tzdata
------------------
Please select the geographic area in which you live. Subsequent configuration questions will narrow this down by presenting a list of cities,
representing the time zones in which they are located.
1. Africa 3. Antarctica 5. Arctic 7. Atlantic 9. Indian 11. SystemV 13. Etc
2. America 4. Australia 6. Asia 8. Europe 10. Pacific 12. US
Geographic area: 6
Please select the city or region corresponding to your time zone.
1. Aden 13. Barnaul 25. Dushanbe 37. Jerusalem 49. Macau 61. Pyongyang 73. Taipei 85. Vientiane
2. Almaty 14. Beirut 26. Famagusta 38. Kabul 50. Magadan 62. Qatar 74. Tashkent 86. Vladivostok
3. Amman 15. Bishkek 27. Gaza 39. Kamchatka 51. Makassar 63. Qostanay 75. Tbilisi 87. Yakutsk
4. Anadyr 16. Brunei 28. Harbin 40. Karachi 52. Manila 64. Qyzylorda 76. Tehran 88. Yangon
5. Aqtau 17. Chita 29. Hebron 41. Kashgar 53. Muscat 65. Rangoon 77. Tel_Aviv 89. Yekaterinburg
6. Aqtobe 18. Choibalsan 30. Ho_Chi_Minh 42. Kathmandu 54. Nicosia 66. Riyadh 78. Thimphu 90. Yerevan
7. Ashgabat 19. Chongqing 31. Hong_Kong 43. Khandyga 55. Novokuznetsk 67. Sakhalin 79. Tokyo
8. Atyrau 20. Colombo 32. Hovd 44. Kolkata 56. Novosibirsk 68. Samarkand 80. Tomsk
9. Baghdad 21. Damascus 33. Irkutsk 45. Krasnoyarsk 57. Omsk 69. Seoul 81. Ujung_Pandang
10. Bahrain 22. Dhaka 34. Istanbul 46. Kuala_Lumpur 58. Oral 70. Shanghai 82. Ulaanbaatar
11. Baku 23. Dili 35. Jakarta 47. Kuching 59. Phnom_Penh 71. Singapore 83. Urumqi
12. Bangkok 24. Dubai 36. Jayapura 48. Kuwait 60. Pontianak 72. Srednekolymsk 84. Ust-Nera
Time zone: 79
Current default time zone: 'Asia/Tokyo'
Local time is now: Sat Jan 8 11:27:04 JST 2022.
Universal Time is now: Sat Jan 8 02:27:04 UTC 2022.
Run 'dpkg-reconfigure tzdata' if you wish to change it.
Setting up libglib2.0-data (2.64.6-1~ubuntu20.04.4) ...
Setting up libx11-data (2:1.6.9-2ubuntu1.2) ...
Setting up libbsd0:amd64 (0.10.0-1) ...
Setting up libxdmcp6:amd64 (1:1.1.3-0ubuntu1) ...
Setting up libxcb1:amd64 (1.14-2) ...
Setting up libicu66:amd64 (66.1-2ubuntu2.1) ...
Setting up libx11-6:amd64 (2:1.6.9-2ubuntu1.2) ...
Setting up libxml2:amd64 (2.9.10+dfsg-5ubuntu0.20.04.1) ...
Setting up wmdocker (1.5-2) ...
Setting up shared-mime-info (1.15-1) ...
Setting up docker (1.5-2) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
root@1957b5c49435:/# docker run -it ubuntu /bin/bash
bash: docker: command not found
root@1957b5c49435:/# /bin/docker
bash: /bin/docker: No such file or directory
root@1957b5c49435:/# /sbin/docker
bash: /sbin/docker: No such file or directory
root@1957b5c49435:/# find / -name docker -print
/usr/share/doc/docker
did 参考資料
Docker in Docker のベタープラクティス
Dockerコンテナ内からDockerを使うことについて
docker in docker(dind)を使ってみる
参考資料
Linuxbrew のススメ
https://qiita.com/thermes/items/926b478ff6e3758ecfea
最後までおよみいただきありがとうございました。
いいね 💚、フォローをお願いします。
Thank you very much for reading to the last sentence.
Please press the like icon 💚 and follow me for your happy life.