geerlingguy / docker-centos6-ansible

CentOS 6.x Docker container for Ansible playbook and role testing.
https://hub.docker.com/r/geerlingguy/docker-centos6-ansible/
MIT License
8 stars 17 forks source link

Cannot start container #11

Closed nkakouros closed 5 years ago

nkakouros commented 5 years ago

I am sorry to bother you with a potential non-issue. I am not so experienced with docker. I use the following commands to start a centos6 container:

docker run --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro geerlingguy/docker-centos6-ansible:latest /sbin/init

My docker version is Docker version 18.09.2-ce, build 62479626f2.

The container simply exits. docker logs returns nothing. Am I doing sth wrong?

BobVanB commented 5 years ago

This article opened my eyes: docker-container-will-automatically-stop-after-docker-run-d Short awnser, there is no foreground process for docker to monitor, then docker will remove it. Start the container with tail -f /dev/null, and docker will not remove it.

Somehow i got this same problem with manjaro, Docker version 18.09.6-ce, build 481bc77156 My colleague with ubuntu LTS, does not have this problem.

geerlingguy commented 5 years ago

@nkakouros - @BobVanB is correct, you are trying to start the container with the command /sbin/init. That command simply stops after it starts because it does not run continuously. You have to start a process that does not die, or monitor /dev/null, or something like that, otherwise the container will stop right away.