Search code examples
dockerdocker-entrypoint

Docker multiple inheriting entry_point execution


I have the following Dockerfile:

FROM gitlab-registry.foo.ru/project/my_project
FROM aerospike/aerospike-server

And above the first and second ones have an ENTRYPOINT. As it known, only one ENTRYPOINT will be executed. Does it exist the way to run all of the parents ENTRYPOINT?

Is it correct, that I can use the Docker-Compose for tasks like this?


Solution

  • From the comments above, there's a fundamental misunderstanding of what docker is doing. A container is an isolated process. When you start a docker container, it starts a process for your application, and when that process exits, the container exits. A good best practice is one application per container. Even though there are ways to launch multiple programs, I wouldn't recommend them, as it complicates health checks, upgrades, signal handling, logging, and failure detection.

    There is no clean way to merge multiple images together. In the Dockerfile you listed, you defined a multi-stage build that could have been used to copy files from the first stage into the final stage. The resulting image will be the last FROM section, not a merge of the two images. The typical use of multi-stage builds is replacing the separate compile images or external build processes, and to have a single command with a compiling image and a runtime image that outputs the application inside the runtime image. This is very different from what you're looking for.

    The preferred method to run multiple applications in docker is as multiple containers from different images, and using docker networking to connect them together. You'll want to start with a docker-compose.yml which can be used by either docker-compose on a standalone docker engine, or with docker stack deploy to use the features of swarm mode.