Source From Here
Question
I'm trying to list services on my CentOS image running in Docker using
but I get this error message:
Any suggestions what the problem might be?
How-To
My guess is that you're running a non-privileged container. systemd requires CAP_SYS_ADMIN capability but Docker drops that capability in the non privileged containers, in order to add more security.
systemd also requires RO access to the cgroup file system within a container. You can add it with –v /sys/fs/cgroup:/sys/fs/cgroup:ro So, here a few steps on how to run CentOS with systemd inside a Docker container:
Question
I'm trying to list services on my CentOS image running in Docker using
but I get this error message:
Any suggestions what the problem might be?
How-To
My guess is that you're running a non-privileged container. systemd requires CAP_SYS_ADMIN capability but Docker drops that capability in the non privileged containers, in order to add more security.
systemd also requires RO access to the cgroup file system within a container. You can add it with –v /sys/fs/cgroup:/sys/fs/cgroup:ro So, here a few steps on how to run CentOS with systemd inside a Docker container:
3. Build it - docker build --rm -t centos7-systemd - < mydockerfile
4. Run a container with docker run --privileged -ti -e container=docker -v /sys/fs/cgroup:/sys/fs/cgroup centos7-systemd /usr/sbin/init
5. You should have systemd in your container
If you want an exist docker image to be capable of systemd, you can try "sethrosetter/centos7-systemd-sshd"
沒有留言:
張貼留言