3. クラスター計算機で udocker を利用する: 基本コマンド編-1
docker hubからイメージを取得してコンテナ環境で実行する
インストール編でudockerのインストールが完了したので、イメージを取得し、コンテナを実際に動かしてみよう
ここでは docker hub上でubuntu(Linux)を検索してみる
docker hub の検索: udocker search イメージ名(一部でも良い)
$ ./udocker search ubuntu
NAME OFFICIAL DESCRIPTION
ubuntu [OK] Ubuntu is a Debian-based Linux operating system based on free software.
ubuntu-debootstrap [OK] debootstrap --variant=minbase --components=main,universe --include=inetutils-ping,iproute2 <suite> /
ubuntu-upstart [OK] Upstart is an event-based replacement for the /sbin/init daemon which starts processes at boot
rastasheep/ubuntu-sshd ---- Dockerized SSH service, built on top of official Ubuntu images.
smartentry/ubuntu ---- ubuntu with smartentry
pivotaldata/ubuntu-gpdb-dev ---- Ubuntu images for GPDB development
pivotaldata/ubuntu ---- A quick freshening-up of the base Ubuntu docker images
darksheer/ubuntu ---- Base Ubuntu Image -- Updated hourly
ppc64le/ubuntu ---- Ubuntu is a Debian-based Linux operating system based on free software.
1and1internet/ubuntu-16-nginx-php-phpmya ---- ubuntu-16-nginx-php-phpmyadmin-mysql-5
nuagebec/ubuntu ---- Simple always updated Ubuntu docker images with SSH access and supervisord.
dorowu/ubuntu-desktop-lxde-vnc ---- Ubuntu with openssh-server and NoVNC
ansible/ubuntu14.04-ansible ---- Ubuntu 14.04 LTS with ansible
neurodebian [OK] NeuroDebian provides neuroscience research software for Debian, Ubuntu, and other derivatives.
1and1internet/ubuntu-16-apache-php-7.0 ---- ubuntu-16-apache-php-7.0
tutum/ubuntu ---- Simple Ubuntu docker images with SSH access
codenvy/ubuntu_jdk8 ---- Ubuntu, JDK8, Maven 3, git, curl, nmap, mc, cbuild
1and1internet/ubuntu-16-healthcheck ---- ubuntu-16-healthcheck
1and1internet/ubuntu-16-nginx-php-5.6-wo ---- ubuntu-16-nginx-php-5.6-wordpress-4
ossobv/ubuntu ---- Custom ubuntu image from scratch (based on original from docker https://hub.docker.com/_/ubuntu/).
1and1internet/ubuntu-16-sshd ---- ubuntu-16-sshd
i386/ubuntu ---- Ubuntu is a Debian-based Linux operating system based on free software.
1and1internet/ubuntu-16-nginx-php-phpmya ---- ubuntu-16-nginx-php-phpmyadmin-mariadb-10
1and1internet/ubuntu-16-apache ---- ubuntu-16-apache
eclipse/ubuntu_jdk8 ---- Ubuntu, JDK8, Maven 3, git, curl, nmap, mc, cbuild
[press return or q to quit]
1画面では収まらない程多数のイメージが登録されている
"q そして 改行"で表示を終了しよう
ここでは、一行目のオフィシャルのubuntuを利用してみる
docker hub からのイメージ取得: udocker pull イメージ
$ ./udocker pull ubuntu
Downloading layer: sha256:1be7f2b886e89a58e59c4e685fcc5905a26ddef3201f290b96f1eff7d778e122
Downloading layer: sha256:6fbc4a21b806838b63b774b338c6ad19d696a9e655f50b4e358cc4006c3baa79
Downloading layer: sha256:c71a6f8e13782fed125f2247931c3eb20cc0e6428a5d79edb546f1f1405f0e49
Downloading layer: sha256:4be3072e5a37392e32f632bb234c0b461ff5675ab7e362afad6359fbd36884af
Downloading layer: sha256:06c6d2f5970057aef3aef6da60f0fde280db1c077f0cd88ca33ec1a70a9c7b58
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
ダンロードするイメージのサイズにより異なるが、数分以上かかる場合も有る
表示されるsha256:1be7f2b886e89a58e59c4e685fcc5905a26ddef3201f290b96f1eff7d778e122
等についてはdocker hub上のイメージがアップデートされれば異なったものとなる
取得されているイメージの表示: udocker images
$ ./udocker images
REPOSITORY
ubuntu:latest .
ubuntuのバージョンを指定していないが、latestのイメージがシステムに存在する事がわかる
他のイメージを既に取得していればその一覧がリスト表示される
docker hub から取得のコンテナを展開: udocker create --name=任意のコンテナの名前 利用するイメージ名
$ ./udocker create --name=ubuntu ubuntu
0ca3cd40-ff32-35c2-a4dd-d0e331ba449c
後のどこかで触れるけれど--name=
でコンテナ名を指定しておく方が良い
このコマンドを実行した時に表示される行0ca3cd40-ff32-35c2-a4dd-d0e331ba449c
についてはそれぞれ異なっているはず
(混乱しないように、コンテナとイメージを違う名前にした方が良いかもしれない)
コンテナの実行: udocker run コンテナ名 実行するコマンド
展開したコンテナを利用して実際にコマンドを実行してみる
まずは、ホストのOSバージョンを確認する
(ここではRed Hat Linuxを想定)
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.1 (Maipo)
コンテナのOS(ubuntu) のバージョンを確認する
./udocker run ubuntu cat /etc/lsb-release
******************************************************************************
* *
* STARTING 0ca3cd40-ff32-35c2-a4dd-d0e331ba449c *
* *
******************************************************************************
executing: cat
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"
コンテナ環境でホストのOSのバージョン確認を行った際のコマンドを実行する
$ ./udocker run ubuntu cat /etc/redhat-release
******************************************************************************
* *
* STARTING 0ca3cd40-ff32-35c2-a4dd-d0e331ba449c *
* *
******************************************************************************
executing: cat
cat: /etc/redhat-release: No such file or directory
コンテナ上にはそのファイルは存在しないのでエラーになる
コンテナ上でディレクトリを表示
udocker run
実行時のバナー等がちょっと邪魔なので、これ以降は-q
オプションを追記してコンテナ起動時の情報が表示されないようにする
ls
でディレクトリの一覧を取得してみる
$ ./udocker -q run ubuntu ls -alr
total 88
drwxr-xr-x 11 root root 4096 Jan 23 22:49 var
drwxr-xr-x 10 root root 4096 Jan 23 22:49 usr
drwxr-xr-x 2 root root 4096 Jan 23 22:49 tmp
dr-xr-xr-x 13 root root 0 Nov 20 00:02 sys
drwxr-xr-x 2 root root 4096 Jan 23 22:49 srv
drwxr-xr-x 2 root root 8192 Jan 25 18:23 sbin
drwxr-xr-x 5 root root 4096 Jan 23 22:49 run
drwx------ 2 root root 4096 Jan 23 22:49 root
dr-xr-xr-x 978 root root 0 Nov 20 00:02 proc
drwxr-xr-x 2 root root 4096 Jan 23 22:49 opt
drwxr-xr-x 2 root root 4096 Jan 23 22:49 mnt
drwxr-xr-x 2 root root 4096 Jan 23 22:49 media
drwxr-xr-x 2 root root 4096 Jan 23 22:49 lib64
drwxr-xr-x 9 root root 4096 Feb 21 05:53 lib
drwxr-xr-x 2 root root 4096 Apr 12 2016 home
drwxr-xr-x 42 root root 8192 Jan 25 18:23 etc
drwxr-xr-x 22 root root 3620 Nov 20 00:03 dev
drwxr-xr-x 2 root root 4096 Apr 12 2016 boot
drwxr-xr-x 2 root root 8192 Jan 23 22:49 bin
-rw------- 1 root root 94 Feb 21 04:58 .bash_history
drwxr-xr-x 21 root root 4096 Feb 21 04:57 ..
drwxr-xr-x 21 root root 4096 Feb 21 04:57 .
コンテナのディレクトリが表示されている
(ルートディレクトリが表示されている)
touch
コマンドを利用して新しい空のファイルを作成し、その属性を表示してみる
$ ./udocker -q run ubuntu touch test.txt
$ ./udocker -q run ubuntu ls -al test.txt
-rw-r--r-- 1 root root 0 Feb 21 06:23 test.txt
作成されたファイルの属性から、この方法でコマンドを実行すると、コンテナの中ではrootの権限で処理される事がわかる
今日はここまで
Author And Source
この問題について(3. クラスター計算機で udocker を利用する: 基本コマンド編-1), 我々は、より多くの情報をここで見つけました https://qiita.com/percipere/items/e70efe47f6b1aad8bb4b著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .