Sign inSign up

naftulikay/centos-vm

By naftulikay

•Updated over 8 years ago

Bare-bones VM in Docker for running CentOS.

Image
0

3.6K

naftulikay/centos-vm repository overview

⁠docker-centos-vm Build Status Docker Build

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.

⁠Running:

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:

--volume=$(pwd):/etc/ansible/roles/$ROLE_NAME:ro

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

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

⁠Contracts

This container must do the following:

⁠Targets
  • :ballot_box_with_check: reach multi-user.target after calling wait-for-boot in the container, in a timely fashion (usually 5s)
⁠Services
  • :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.
⁠Commands
  • :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

Tag summary

Content type

Image

Digest

Size

93.3 MB

Last updated

over 8 years ago

docker pull naftulikay/centos-vm