2

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?

voltento
  • 833
  • 10
  • 26
  • Can you clarify what you believe the above Dockerfile does or what you want it to do? Were you hoping to merge two images together into one? – BMitch Jan 31 '18 at 13:18
  • @BMitch For example, I have two docker images, both start the program, for example, the first one starts the Aerospike, and the second one starts the Nginx. All of them start the work with an entry point. So, is there exists the way to form a third docker file which will start Aerospike and Nginx services? I thought, that I can do this with the docker file, that has shown in my answer. By it starts either firth 'my-project' or second 'aerospike'. – voltento Feb 01 '18 at 06:15
  • 1
    why do I have a negative score on this question? How can I improve this one? – voltento Mar 12 '18 at 08:17
  • Not sure where the -1 came from, but if I were to guess, it's the open ended question about compose at the end combined with a two line docker file that points to external references. See [mcve] for more on writing a better question. – BMitch Mar 12 '18 at 11:14
  • I think you were talking about multistage dockerfile because you used multiple `FROM`, but you didn't say it in your question. – august0490 Mar 25 '21 at 01:56

2 Answers2

3

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.

BMitch
  • 231,797
  • 42
  • 475
  • 450
2

Simple answer is No.

Your Dockerfile uses Docker Multi-Stage builds which are used to transfer dependencies from one image to another. The last FROM statement is the base image for the resulting image.

The entrypoint from base image will only be inherited. You need to exlicilty set the entrypoint if you want a different one from that specified in the base image coming from the last FROM instruction.

yamenk
  • 46,736
  • 10
  • 93
  • 87