0

This questions must have been asked many times before but i can't find any solution that can help me solve my problem.

I'm running VueJS application with Express/NodeJS as server and I know the best way is probably to separate them in 2 containers. But how can I make this work in 1 container with multi-stage or any other way.

Any tips would be appreciated! Thank you!

2
  • Normally one container serve one service (anything that runs on a port) and usually that is the default entry-point for the image/container. In case (without thinking why you need them together in 1 container) you need both services in 1 container - you need to override entrypoint with a custom script that must launch desired services (launch 1st service in background and then launch 2nd service in foreground.) Commented Dec 14, 2022 at 6:37
  • Thank you @fly2matrix . You got some articles about this issue? Because its against docker it's hard to find any good articles/tutorials about this. Commented Dec 14, 2022 at 10:17

1 Answer 1

1

Run multiple services in a container

A container’s main running process is the ENTRYPOINT and/or CMD at the end of the Dockerfile. It is generally recommended that you separate areas of concern by using one service per container. That service may fork into multiple processes (for example, Apache web server starts multiple worker processes). It’s ok to have multiple processes, but to get the most benefit out of Docker, avoid one container being responsible for multiple aspects of your overall application. You can connect multiple containers using user-defined networks and shared volumes.
If you need to run more than one service within a container, you can accomplish this in a few different ways.

Reference: https://docs.docker.com/config/containers/multi-service_container/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.