Bare-bones VM in Docker for running CentOS.
3.6K
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.
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
This container must do the following:
multi-user.target after calling wait-for-boot in the container, in a timely fashion (usually 5s)dbus.servicesystemd-journald.servicesystemd-timedated.service/etc/machine-id in a pseudorandom fashion on every container boot.hostnamectltimedatectljournalctlContent type
Image
Digest
Size
93.3 MB
Last updated
over 8 years ago
docker pull naftulikay/centos-vm