Docker Hubで公開されたCentOS 8を試してみる

# はじめに

Docker HubにCentOS8が登場したので動作確認。

## 環境

Windows10 - HyperV上で動作しているCoreOS(ContainerOS)で起動

### イメージダウンロード

```shell-session
core@coreos ~ $ docker pull centos:8
8: Pulling from library/centos
729ec3a6ada3: Pull complete
Digest: sha256:f94c1d992c193b3dc09e297ffd54d8a4f1dc946c37cbeceb26d35ce1647f88d9
Status: Downloaded newer image for centos:8
```

### CentOS8起動

```shell-session
core@coreos ~ $ docker run -it --rm centos:8
[root@3c4ae9aaf4ef /]# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core)
[root@3c4ae9aaf4ef /]#
```

### 各種確認

```shell-session
[root@3c4ae9aaf4ef /]# yum module list
Failed to set locale, defaulting to C
CentOS-8 - AppStream                                                          227 kB/s | 5.6 MB     00:25
CentOS-8 - Base                                                               1.0 MB/s | 5.3 MB     00:05
CentOS-8 - Extras                                                             277  B/s | 2.1 kB     00:07
CentOS-8 - AppStream
Name                 Stream     Profiles                  Summary
389-ds               1.4                                  389 Directory Server (base)
ant                  1.10 [d]   common [d]                Java build tool
container-tools      1.0        common [d]                Common tools and dependencies for container runtimes
container-tools      rhel8 [d]  common [d]                Common tools and dependencies for container runtimes
freeradius           3.0 [d]    server [d]                High-performance and highly configurable free RADIUS
                                                           server
gimp                 2.8 [d]    common [d], devel         gimp module
go-toolset           rhel8 [d]  common [d]                Go
httpd                2.4 [d]    common [d], devel, minima Apache HTTP Server
                                l
idm                  DL1        common [d], adtrust, clie The Red Hat Enterprise Linux Identity Management sys
                                nt, dns, server           tem module
idm                  client [d] common [d]                RHEL IdM long term support client module
inkscape             0.92.3 [d] common [d]                Vector-based drawing program using SVG
javapackages-runtime 201801 [d] common [d]                Basic runtime utilities to support Java applications
libselinux-python    2.8        common                    Python 2 bindings for libselinux
llvm-toolset         rhel8 [d]  common [d]                LLVM
mailman              2.1 [d]    common [d]                Electronic mail discussion and e-newsletter lists ma
                                                          naging software
mariadb              10.3 [d]   client, server [d], galer MariaDB Module
                                a
maven                3.5 [d]    common [d]                Java project management and project comprehension to
                                                          ol
mercurial            4.8 [d]    common [d]                Mercurial -- a distributed SCM
mod_auth_openidc     2.3                                  Apache module suporting OpenID Connect authenticatio
                                                          n
mysql                8.0 [d]    client, server [d]        MySQL Module
nginx                1.14 [d]   common [d]                nginx webserver
nodejs               10 [d]     common [d], development,  Javascript runtime
                                minimal, s2i
parfait              0.5        common                    Parfait Module
perl                 5.24       common [d], minimal       Practical Extraction and Report Language
perl                 5.26 [d]   common [d], minimal       Practical Extraction and Report Language
perl-App-cpanminus   1.7044 [d] common [d]                Get, unpack, build and install CPAN modules
perl-DBD-MySQL       4.046 [d]  common [d]                A MySQL interface for Perl
perl-DBD-Pg          3.7 [d]    common [d]                A PostgreSQL interface for Perl
perl-DBD-SQLite      1.58 [d]   common [d]                SQLite DBI driver
perl-DBI             1.641 [d]  common [d]                A database access API for Perl
perl-FCGI            0.78 [d]   common [d]                FastCGI Perl bindings
perl-YAML            1.24 [d]   common [d]                Perl parser for YAML
php                  7.2 [d]    common [d], devel, minima PHP scripting language
                                l
pki-core             10.6                                 PKI Core
pki-deps             10.6                                 PKI Dependencies
postgresql           10 [d]     client, server [d]        PostgreSQL server and client module
postgresql           9.6        client, server [d]        PostgreSQL server and client module
python27             2.7 [d]    common [d]                Python programming language, version 2.7
python36             3.6 [d]    common [d], build         Python programming language, version 3.6
redis                5 [d]      common [d]                Redis persistent key-value database
rhn-tools            1.0 [d]    common [d]                Red Hat Satellite 5 tools for RHEL
ruby                 2.5 [d]    common [d]                An interpreter of object-oriented scripting language
rust-toolset         rhel8 [d]  common [d]                Rust
satellite-5-client   1.0 [d]    common [d], gui           Red Hat Satellite 5 client packages
scala                2.10 [d]   common [d]                A hybrid functional/object-oriented language for the
                                                           JVM
squid                4 [d]      common [d]                Squid - Optimising Web Delivery
subversion           1.10 [d]   common [d], server        Apache Subversion
swig                 3.0 [d]    common [d], complete      Connects C/C++/Objective C to some high-level progra
                                                          mming languages
varnish              6 [d]      common [d]                Varnish HTTP cache
virt                 rhel [d]   common [d]                Virtualization module

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

[root@3c4ae9aaf4ef /]# yum install -y php
... 略

[root@3c4ae9aaf4ef /]# php -v
PHP 7.2.11 (cli) (built: Oct  9 2018 15:09:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

[root@3c4ae9aaf4ef /]# php-fpm -v
PHP 7.2.11 (fpm-fcgi) (built: Oct  9 2018 15:09:36)
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

[root@3c4ae9aaf4ef /]# systemctl status php-fpm
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
```

CentOS7のイメージと同様にサービスが起動しない。
対応方法は同じで良さそう。

ちなみにこっちは現時点では7
https://hub.docker.com/r/centos/systemd

```shell-session
core@coreos ~ $ docker run --privileged --name centos -d --rm centos:8 /sbin/init
80698c5a6158853c1a220aa7a6cf9e1d4453d03e12c1bbf2e80754bcf603e232
core@coreos ~ $ docker exec -it centos bash

[root@80698c5a6158 /]# yum install -y php
... 略

[root@80698c5a6158 /]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

[root@80698c5a6158 /]# systemctl start php-fpm
[root@80698c5a6158 /]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-10-02 11:21:24 UTC; 8min ago
 Main PID: 237 (php-fpm)
   Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec"
    Tasks: 6 (limit: 8989)
   Memory: 18.2M
   CGroup: /docker/80698c5a6158853c1a220aa7a6cf9e1d4453d03e12c1bbf2e80754bcf603e232/system.slice/php-fpm.service
           tq237 php-fpm: master process (/etc/php-fpm.conf)
           tq238 php-fpm: pool www
           tq239 php-fpm: pool www
           tq240 php-fpm: pool www
           tq241 php-fpm: pool www
           mq242 php-fpm: pool www

Oct 02 11:21:24 80698c5a6158 systemd[1]: Starting The PHP FastCGI Process Manager...
Oct 02 11:21:24 80698c5a6158 systemd[1]: Started The PHP FastCGI Process Manager.
```