ENABLE SYSTEMCTL COMMAND IN DOCKER CONTAINER

Hey, All Here I’m Going To Show All of You How To Enable systemctl command in the Docker and launch the httpd server in it.

Container Docker

So This has been a pain for many folks how to run the systemctl command in docker.
Here I’m going to Show All of you How To install the httpd server in Docker Container.

STEP 1:
Pull any docker image, here I’m using the centos

Docker pull

And After that run the container using the command

docker run -itd --privileged -p 80:80 --name httpd centos:latest /usr/sbin/init

STEP 2:
Now, to get the shell of that container get the container id which looks like this

Docker container id

And after that Run the Following Command

docker exec -it <container name> /bin/bash

and after that install the httpd using yum command

yum install httpd -y

And After that, use the systemctl command to enable the service

systemctl command
service is running

Hence The systemctl command is working in the docker container

HOPE THIS WILL HELP YOU ALL!!