Docker RUN multiple instance of a image with different parameters Docker RUN multiple instance of a image with different parameters docker docker

Docker RUN multiple instance of a image with different parameters


Docker containers are started with an entrypoint and a command; when the container actually starts they are simply concatenated together. If the ENTRYPOINT in the Dockerfile is structured like a single command then the CMD in the Dockerfile or command: in the docker-compose.yml contains arguments to it.

This means you should be able to set up your docker-compose.yml as:

services:  my.app1:    image: ${DOCKER_REGISTRY}my/app    ports:     - 5000:80    command: [80, db1.db]  my.app2:    image: ${DOCKER_REGISTRY}my/app    ports:     - 5001:80    command: [80, db2.db]

(As a side note: if one of the options to the program is the port to listen on, this needs to match the second port in the ports: specification, and in my example I've chosen to have both listen on the "normal" HTTP port and remap it on the hosts using the ports: setting. One container could reach the other, if it needed to, as http://my.app2/ on the default HTTP port.)