centos - Operation not permitted systemctl with docker + systemctl -
dockerfile
from centos:7 env container docker volume ["/sys/fs/cgroup"] run yum -y update run yum install -y httpd run systemctl start httpd.service add . /code workdir /code
docker-compose.yml
version: '2' services: web: privileged: true build: . ports: - "80:80" volumes: - .:/code
command
docker-compose build
error:
step 6 : run systemctl start httpd.service ---> running in 5989c6576ac9 ?[91mfailed d-bus connection: operation not permitted ?[0m?[31merror?[0m: service 'web' failed build: command '/bin/sh -c syste mctl start httpd.service' returned non-zero code: 1
obs: running on windows 7 :(
any tip?
as explained in centos docker image repository, systemd not active default. in order use systemd, need include text similar example dockerfile below:
from centos:7 maintainer "you" <your@email.here> env container docker run (cd /lib/systemd/system/sysinit.target.wants/; in *; [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ rm -f /lib/systemd/system/multi-user.target.wants/*;\ rm -f /etc/systemd/system/*.wants/*;\ rm -f /lib/systemd/system/local-fs.target.wants/*; \ rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ rm -f /lib/systemd/system/basic.target.wants/*;\ rm -f /lib/systemd/system/anaconda.target.wants/*; volume [ "/sys/fs/cgroup" ] cmd ["/usr/sbin/init"]
this dockerfile deletes number of unit files might cause issues. here, ready build base image.
$ docker build --rm -t local/c7-systemd .
in order use systemd enabled base container created above, need change dockerfile to:
from local/c7-systemd env container docker volume ["/sys/fs/cgroup"] run yum -y update run yum install -y httpd run systemctl start httpd.service add . /code workdir /code
Comments
Post a Comment