Running multiple docker containers from same image but different arguments

Viewed 33

I have the following Dockerfile to run a java jar file, which is basically creating a database schema using liquibase. As you see, I am passing the schema name as environment variable in the Dockerfile.

Now, in the same database we are going to have multiple schemas, so the use case is that we would need to run multiple containers from the same image, but each container with a different database schema name, or maybe having multiple entry points with different arguments. If we have 100 different schemas, we want to avoid changing the schema name manually and running the container 100 times. Instead I want to be able to provide a list of schemas and be able to run automatically 100 containers with a different schema.

I don't know what is the best/cleanest way to achieve what we need. Any docker expert could help?

FROM openjdk:8-jdk-alpine

ENV host=host.docker.internal
ENV schema=mydbschame
ENV username=username
ENV password=somepassword

EXPOSE 8080
ARG JAR_FILE=database-local.jar
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
0 Answers
Related