This might be a bit of a confused question...

I've recently started playing around with docker and am trying to setup a basic lamp server.

I have a docker image of centos with httpd, php, and mysql.

However, in a docker container I can't start services in the way I would usually do via systemd / service.

I can get httpd running directly via /usr/sbin/httpd

So then what if any is the difference in running httpd via /usr/sbin/httpd rather than via systemctl start httpd?

Is there a 'proper' way to stop or restart httpd? - I thought I could just kill the process but it appears to launch about 10 apache processes.

I appreciate this isn't a particularly well focused question but any pointer to relevant material would be gratefully received.


You cannot use systemctl If your PID 1 is not systemd. You can find your PID 1 with ps -q 1.

Being able to start and stop services the normal way is one advantage mentioned in this article about Running systemd in a non-privileged container. Others are logging or tracking of child processes as described in Andrei's answer.


A systemd service will start the process in a similar fashion to running it directly however it will keep track of all the forked processes and threads. This means that when you systemctl stop apache it will shutdown all of the child processes. Also using systemd processes is nice because they will run in background and can be started on system startup.


Considering your location on the learning curve, I would not use Docker for your task.

If you are using Docker for process isolation, you can use unique Unix users for that, or systemd also includes directives to limit what a systemd service can access. See for example Capabilities= in man systemd.exec.

Also, for process isolation with Docker you would run each of the the database and web server in different Docker containers.

Another important feature that systemd provides is process management. That is-- if your httpd process crashes, systemd will restart it for you.

My recommendation is to first get all your processes running directly on a host server using systemd. Many modern packages come with systemd configuration files already.

Once you have a good understanding of systemd are are clear what benefit adding Docker will provide, then consider Docker to the mix.

At my job, we tried using Docker to manage a set of services but later used to managing directly with systemd and the result is a cleaner system that the team prefers with less bash scripts to glue things together and maintain them.

  • I have all the processors running on the host ok. The impetus for using docker was to be able to use different versions of php. On this machine I have Fedora 25 which comes with php7 but I have to work on an old project that needs php5.6.
    – jx12345
    Apr 18 '17 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.