A
A
Andreo2019-12-11 14:43:00
Docker
Andreo, 2019-12-11 14:43:00

Why is the service not starting inside the Docker container?

I'm experimenting with Docker and ran into a moment that is not yet obvious to me.
Taking as a basis the image with ubuntu in the Dockerfile, I registered the installation of Apache. Everything was installed and the container was up, but not apache. Why didn't it rise if the service is started manually (from the container)?
Dockerfile:

FROM ubuntu

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

VOLUME ["/var/www/html"]

CMD tail -f /dev/null

What I do in detail:
[email protected]:~/www/zetazet.local$ docker build -t=zzz .
Sending build context to Docker daemon  3.072kB
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
[email protected]:~/www/zetazet.local$ docker images | grep zzz
zzz                 latest              513b0fbe2ebf        About an hour ago   188MB
[email protected]:~/www/zetazet.local$ 
[email protected]:~/www/zetazet.local$ 
[email protected]:~/www/zetazet.local$ docker run --name=zzzc -d zzz
7391cf5c5b4c4cacd276a0def1103da941420c67efde2a02c1611690aa13bd65
[email protected]:~/www/zetazet.local$ 
[email protected]:~/www/zetazet.local$ 
[email protected]:~/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
[email protected]:~/www/zetazet.local$ 
[email protected]:~/www/zetazet.local$ 
[email protected]:~/www/zetazet.local$ docker exec -it zzzc bash
[email protected]:/# 
[email protected]:/# 
[email protected]:/# service apache2 status
 * apache2 is not running
[email protected]:/# 
[email protected]:/# 
[email protected]:/# 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
[email protected]:/#

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2019-12-11
@q2digger

Why did he have to get up? Where is the application start command?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question