Public | Automated Build

Last pushed: 2 months ago
Short Description
Bare-bones VM in Docker for running CentOS.
Full Description


A lightweight CentOS VM in Docker. Based on geerlingguy/docker-centos7-ansible, do read the author's
excellent post about testing Ansible across multiple operating systems.

Published to the Docker Hub as naftulikay/centos-vm.


CentOS 7 uses systemd as an init system, so it requires running in --privileged mode with at least read-only access
to the /sys/fs/cgroup socket:

docker run --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro naftulikay/centos-vm:7

The container ID will be emitted by Docker and this can be used to execute commands in the Docker container/"VM".

A lot of the work to discover what was necessary for systemd to run in Docker was provided by the
SELinux Man Himself, Dan Walsh, in a RedHat blog post.

Testing Ansible Roles

To test Ansible roles, pass something of the following to mount your role and execute your tests against it:


When starting the container, a container ID is emitted; this can be saved and used to execute commands within the Docker

docker exec --tty $CONTAINER_ID env TERM=xterm ansible --version
docker exec --tty $CONTAINER_ID env TERM=xterm ansible-playbook /path/to/ansible/playbook.yml --syntax-check


This container must do the following:


  • :ballot_box_with_check: reach after calling wait-for-boot in the container, in a timely fashion (usually 5s)


  • :ballot_box_with_check: enable dbus.service
  • :ballot_box_with_check: enable systemd-journald.service
  • :ballot_box_with_check: enable systemd-timedated.service
  • :ballot_box_with_check: generate /etc/machine-id in a pseudorandom fashion on every container boot.


  • :ballot_box_with_check: be able to interact with hostnamectl
  • :ballot_box_with_check: be able to interact with timedatectl
  • :ballot_box_with_check: be able to interect with journalctl
Docker Pull Command
Source Repository