I have built a docker image. There I am using the yocto built rootfs. The systemd is already integrated with that rootfs. but when I login into the container using "docker exec -it mycontainer_name sh " and I am trying to start an application through systemctl command i.e. “systemctl start app_name.service”. But I am getting below error:
System has not been booted with systemd as init system (PID 1). Can’t operate.
My Docker file looks like this:
FROM scratch ADD My_dev_env.rootfs.tar.bz2 / #copy the executables required inside the docker image COPY some_test.sh /usr/bin/ #set the work directory for image WORKDIR /usr/bin RUN chmod 777 /usr/bin/some_test.sh #Tell image what to do on runnig as a container CMD ["./some_test.sh "]
And I am running this docker container as systemd service on my host my docker_service file is as below:
[Unit] Description=run_rungdptest Container After=docker.service Requires=docker.service [Service] Type=simple User=root TimeoutStartSec=0 ExecStartPre=-/usr/bin/docker rm docker_container_name ExecStart=/usr/bin/docker run \ --name docker_container_name \ docker_image_name ExecStop=/usr/bin/docker stop docker_container_name Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target
But, even the systemd is already integrated in the rootfs that I am using here. Eventhen systemd is not working inside the docker container. Can anybody suggest me on this, how can I make systemd working please. Any suggestion will help me a lot.