LoginSignup
1
0

More than 3 years have passed since last update.

io_uringを使うプログラムはCentOS 8上のDockerでは動かない

Last updated at Posted at 2020-12-18

Linux kernel 5.1から導入されたio_uringという非同期IOのカーネル機能がありますが、それを使うDockerイメージはCentOS 8で動きませんよと。
知ってる人にはまあ、そうだよねという事ではあるのですが。

Docker/Linuxコンテナのポータビリティは万能ではないんですよと議論したい場合の論拠として。

io_uring使うプログラムをUbuntu 20.10で作る

1.OSがUbuntu 20.10の仮想マシンを作る。
https://ubuntu.com/download

2.Dockerをインストールする。
https://docs.docker.com/engine/install/ubuntu/

3.Docker上でUbuntu 20.10イメージを起動する。
# docker run -it --rm --name=io_uring-test ubuntu:20.10 bash

4.一応、uname -aで利用中のカーネルを確認。
(c)# uname -a

(実行結果)
root@17003dd74a2f:/liburing/examples# uname -a
Linux 17003dd74a2f 5.8.0-33-generic #36-Ubuntu SMP Wed Dec 9 09:14:40 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

5.gccとio_uringのライブラリ、gitをインストールする。
(c)# apt-get update
(c)# apt-get install -y build-essential liburing-dev git

6.io_uringのサンプルプログラムを入手する。
https://blogs.oracle.com/linux/an-introduction-to-the-io_uring-asynchronous-io-framework
(c)# git clone https://github.com/axboe/liburing.git

7.サンプルプログラムをコンパイルする。
(c)# cd liburing/examples
(c)# gcc -Wall -O2 -D_GNU_SOURCE -o io_uring-test io_uring-test.c -luring

8.プログラムを実行する。当然、こちらは動作する。
(c)# ./io_uring-test io_uring-test.c

(実行結果)
root@08ad6f4c804c:/liburing/examples# ./io_uring-test io_uring-test.c
Submitted=1, completed=1, bytes=2256

9.コンテナからデタッチ(C-p, C-q)し、コミット、イメージ保存する。
# docker commit io_uring-test io_uring-test
# docker save io_uring-test -o io_uring-test.tar

CentOS 8のDockerでそのプログラムを動かす

1.OSがCentOS 8.3の仮想マシンを作る。
https://www.centos.org/download/

2.Dockerをインストールする。
https://docs.docker.com/engine/install/centos/

3.先のDockerイメージ(io_uring-test.tar)をCentOS 8マシンにコピーし、ロードする。
# docker load -i io_uring-test.tar

4.コンテナを起動する。
# docker run -it --rm io_uring-test bash

5.一応、uname -aで利用中のカーネルを確認。ホストのCentOS 8と同じ4.18なはず。
(c)# uname -a

(実行結果)
root@824c737193b6:/# uname -a
Linux 824c737193b6 4.18.0-240.1.1.el8_3.x86_64 #1 SMP Thu Nov 19 17:20:08 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

(ついでに)
root@824c737193b6:/liburing/examples# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.10 (Groovy Gorilla)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.10"
VERSION_ID="20.10"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=groovy
UBUNTU_CODENAME=groovy

5.サンプルプログラムを動かす。
(c)# cd liburing/examples/
(c)# ./io_uring-test io_uring-test.c

(実行結果)
root@824c737193b6:/liburing/examples# ./io_uring-test io_uring-test.c
queue_init: Function not implemented

まあ、動きませんよね、と。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0