Public | Automated Build

Last pushed: a month ago
Short Description
A lightweight Ubuntu 16.04 Xenial VM in Docker.
Full Description


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

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


Ubuntu 16.04 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/xenial-vm:latest

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 be provided by the
SELinux Man Himself, Dan Walsh, in some RedHat documentation.

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-timesyncd.service (despite being in Docker)
  • :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 interact with journalctl
Docker Pull Command
Source Repository