How is this possible? CentOS container on Ubuntu (newbie question)

The docker server runs on any Linux os. E.g. I installed docker on an Ubuntu 16.04 machine:

$ docker info
...
Server Version: 1.12.1
Storage Driver: overlay2
Kernel Version: 4.4.0-31-generic
Operating System: Ubuntu 16.04.1 LTS

Now I can create a container from any image. Remember docker image can be based on (Dockerfile FROM) any Linux distro.

All the containers running on a docker server share the kernel, but otherwise are like little, independent virtual machines.

$ docker run -d  --name mycentos7apache -p 80:80 centos:centos7 bash -c 'yum install -y httpd && apachectl -DFOREGROUND'
2d162d934470123109030cf22fc0ad74329f5c0000d7b2030c51e9e329050d48

$ docker logs -f mycentos7apache &
...(yum)...
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message

$ curl --head http://192.168.2.61:80   # substitute your docker server's ip
HTTP/1.1 403 Forbidden
Date: Sun, 04 Sep 2016 23:06:01 GMT
Server: Apache/2.4.6 (CentOS)
...

$ docker exec -ti mycentos7apache cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core) 

Hope that makes sense. Running systemd in your container is problematic at the moment. See https://hub.docker.com/_/centos/ and https://github.com/CentOS/sig-cloud-instance-images/issues/54 for more info.

1 Like