H
H
HellWalk2019-09-20 11:37:30
Docker
HellWalk, 2019-09-20 11:37:30

Why can some images run in the background while others can't?

Simple example, create docker-compose.yml with content:

version: '3.1'

services:

  ubuntu:
    image: ubuntu

  postgres:
    image: postgres:9.6

  php-fpm:
    image: otezvikentiy/php7.2-fpm:0.0.11

  web:
    image: "debian:stretch-slim"

Run:
docker-compose up -d
Starting docker_d_php-fpm_1  ... done
Starting docker_d_ubuntu_1   ... done
Starting docker_d_postgres_1 ... done
Starting docker_d_web_1      ... done

Then:
docker ps
CONTAINER ID        IMAGE                            COMMAND                  CREATED             STATUS              PORTS               NAMES
d3d6dfbafbd0        otezvikentiy/php7.2-fpm:0.0.11   "docker-php-entryp..."   4 minutes ago       Up 2 minutes        22/tcp, 9000/tcp    docker_d_php-fpm_1
3271a44ede0f        postgres:9.6                     "docker-entrypoint..."   6 minutes ago       Up 2 minutes        5432/tcp            docker_d_postgres_1

Postgres and php-fpm run successfully in the background, but ubuntu and debian don't.
Why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2019-09-20
@HellWalk

Because in order for the docker container to remain running in the background, you need a running process in the container to serve it.
ubuntu and debian exit after startup because there are no running processes
and Postgres and php-fpm start the appropriate processes in their container
As a hack - adding for example a line to the container in docker-compose:
you keep the container running in the background, because the container will serve the process tail -f /dev/null

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question