Why not start services inside a Docker container?

Experimenting with Docker and faced with the as yet non-obvious for yourself in the moment.

Taking as a basis the image with the Dockerfile in Ubuntu ordered the installation of Apache. Everything was installed and the container has risen, but not apache. Why doesn't he Padalka if you manually (from container) the service starts?

Dockerfile:
FROM ubuntu

RUN apt-get update && \
 apt-get install apache2-y

VOLUME ["/var/www/html"]

CMD tail-f /dev/null


What to do in detail:
figaro@figaro-pc:~/www/zetazet.local$ docker build-t=zzz .
Sending build context to Docker daemon 3.072 kB
Step 1/4 : FROM ubuntu
 ---> 775349758637
Step 2/4 : RUN apt-get update && apt-get install apache2-y
 ---> Using cache
 ---> 1c6921e410fa
Step 3/4 : VOLUME ["/var/www/html"]
 ---> Using cache
 ---> 62dd54116023
Step 4/4 : CMD tail-f /dev/null
 ---> Using cache
 ---> 513b0fbe2ebf
Successfully built 513b0fbe2ebf
Successfully tagged zzz:latest
figaro@figaro-pc:~/www/zetazet.local$ docker images | grep zzz
zzz latest 513b0fbe2ebf About an hour ago 188MB
figaro@figaro-pc:~/www/zetazet.local$ 
figaro@figaro-pc:~/www/zetazet.local$ 
figaro@figaro-pc:~/www/zetazet.local$ docker run --name=zzzc -d zzz
7391cf5c5b4c4cacd276a0def1103da941420c67efde2a02c1611690aa13bd65
figaro@figaro-pc:~/www/zetazet.local$ 
figaro@figaro-pc:~/www/zetazet.local$ 
figaro@figaro-pc:~/www/zetazet.local$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7391cf5c5b4c zzz "/bin/sh -c 'tail-f..." 7 seconds ago Up 6 seconds zzzc
figaro@figaro-pc:~/www/zetazet.local$ 
figaro@figaro-pc:~/www/zetazet.local$ 
figaro@figaro-pc:~/www/zetazet.local$ docker exec -it bash zzzc
root@7391cf5c5b4c:/# 
root@7391cf5c5b4c:/# 
root@7391cf5c5b4c:/# service apache2 status
 * apache2 is not running
root@7391cf5c5b4c:/# 
root@7391cf5c5b4c:/# 
root@7391cf5c5b4c:/# service apache2 start && service apache2 status
 * Starting Apache httpd web server apache2 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
 * 
 * apache2 is running
root@7391cf5c5b4c:/#
April 3rd 20 at 17:29
1 answer
April 3rd 20 at 17:31
And why did he have to climb? Where the team start the app ?
And why did he have to climb?

Are you asking me? How do I know. The system starts and start services.

Detail what they do:
figaro@figaro-pc:~/www/zetazet.local$ docker build-t=zzz .
Sending build context to Docker daemon 3.072 kB
Step 1/4 : FROM ubuntu
 ---> 775349758637
Step 2/4 : RUN apt-get update && apt-get install apache2-y
 ---> Using cache
 ---> 1c6921e410fa
Step 3/4 : VOLUME ["/var/www/html"]
 ---> Using cache
 ---> 62dd54116023
Step 4/4 : CMD tail-f /dev/null
 ---> Using cache
 ---> 513b0fbe2ebf
Successfully built 513b0fbe2ebf
Successfully tagged zzz:latest
figaro@figaro-pc:~/www/zetazet.local$ docker images | grep zzz
zzz latest 513b0fbe2ebf About an hour ago 188MB
figaro@figaro-pc:~/www/zetazet.local$ 
figaro@figaro-pc:~/www/zetazet.local$ 
figaro@figaro-pc:~/www/zetazet.local$ docker run --name=zzzc -d zzz
7391cf5c5b4c4cacd276a0def1103da941420c67efde2a02c1611690aa13bd65
figaro@figaro-pc:~/www/zetazet.local$ 
figaro@figaro-pc:~/www/zetazet.local$ 
figaro@figaro-pc:~/www/zetazet.local$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7391cf5c5b4c zzz "/bin/sh -c 'tail-f..." 7 seconds ago Up 6 seconds zzzc
figaro@figaro-pc:~/www/zetazet.local$ 
figaro@figaro-pc:~/www/zetazet.local$ 
figaro@figaro-pc:~/www/zetazet.local$ docker exec -it bash zzzc
root@7391cf5c5b4c:/# 
root@7391cf5c5b4c:/# 
root@7391cf5c5b4c:/# service apache2 status
 * apache2 is not running
root@7391cf5c5b4c:/# 
root@7391cf5c5b4c:/# 
root@7391cf5c5b4c:/# service apache2 start && service apache2 status
 * Starting Apache httpd web server apache2 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
 * 
 * apache2 is running
root@7391cf5c5b4c:/#
- Enrico commented on April 3rd 20 at 17:34
the system does not start, start the container. the services also do not rise, they will start in the order determined by the initialization scripts.
in the Docker container to start (and not to fall, i.e. to be active) process, you made him so
CMD tail-f /dev/null
And I had to start Apache with a configuration file and a set of parameters.
See how it's done from the authors of the official container
https://github.com/docker-library/httpd/tree/master/2.4 - isaias_Ryan commented on April 3rd 20 at 17:37

Find more questions by tags Docker