Docker – Multiple processes in one container

 

This example shows how to run 2 JAR files in one container.

As the base image we will use "phusion/baseimage"

First you need to create startup scripts, for convenience, in the example they will be called "start-first.sh" and "start-second.sh", in them we describe the launch of JAR files, for example

start-first.sh

#!/bin/bash
java -jar /usr/src/app/first.jar

 

start-second.sh

#!/bin/bash
java -jar /usr/src/app/second.jar

 

And create a Dockerfile

FROM phusion/baseimage:latest

CMD ["/sbin/my_init"]

RUN add-apt-repository ppa:openjdk-r/ppa && \
    apt-get update -q && \
    apt install -y openjdk-11-jdk

COPY ./my_application /usr/src/app

WORKDIR /usr/src/app

# Add first service
RUN mkdir /etc/service/first
ADD start-first.sh /etc/service/first/run
RUN chmod +x /etc/service/first/run

# Add second service
RUN mkdir /etc/service/second
ADD start-second.sh /etc/service/second/run
RUN chmod +x /etc/service/second/run

# Clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
0 0 vote
Article Rating

Tagged: Tags

Подписаться
Уведомление о
guest
0 Comments
Inline Feedbacks
View all comments