Currently I have a dockerfile that runs two executables using an ampersand:
FROM <Linux base image>
CMD ["bin/sh", "-c", "/service1 & /service2"]
As I am looking to migrate this dockerfile to distroless, I will no longer be able to run this ampersand command, since my new minimal image will no longer have a shell to recognize it. Thus I am looking for alternate ways to ensure I can run both services from the same image.
As an alternative, I am experimenting with doing something like this:
FROM <minimal base image>
RUN /service1
CMD ["/service2"]
Is there any issue with executing /service1 using the RUN command? Is this even possible, given /service1 will be a process running on the container?
Note: I am aware it is not usually recommended to run two services from the same container, but this is to help me better understand RUN and CMD commands. I have read through Dockerfile reference but it is still unclear to me. I have also tested this out locally and the container fails to run, although I do not see logs to confirm this is the reason.