By Isaak
Is it possible to host two different applications like ASP.NET Core (C#) and SpringBoot (Java) side by side in a droplet?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hi there,
Yes, this is totally doable. What I would personally do here would be to use Docker. That way your apps will be isolated and you will not have to install all of the dependencies on your server directly but you would only run your containers.
You can start with the Docker 1-Click image from the Marketplace here:
Then if your apps are not Dockerized yet, you could do that by following these steps here:
For your ASP.NET Core app:
Publish your ASP.NET Core application:
dotnet publish -c Release
Create a Dockerfile
in the root of your ASP.NET Core project:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime
WORKDIR /app
COPY published/ ./
ENTRYPOINT ["dotnet", "your_app.dll"]
For your your SpringBoot application, if it runs as a JAR, create a Dockerfile
in the root of your SpringBoot project:
FROM openjdk:11
MAINTAINER baeldung.com
COPY target/docker-java-jar-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
Then you can build your Docker images and start your containers on your Droplet.
Navigate to each project’s directory and build the Docker images:
# For ASP.NET Core
docker build -t aspnetcoreapp .
# For SpringBoot
docker build -t springbootapp .
Now, you can run each application in its own Docker container:
docker run -d -p 8080:80 aspnetcoreapp
docker run -d -p 9090:8080 springbootapp
Your ASP.NET Core application should be accessible at http://your_droplet_ip:8080
and your SpringBoot application at http://your_droplet_ip:9090
.
Next, you can add Nginx to work as a reverse proxy so you don’t have to specify your ports.
A few things that you could consider are:
Docker Compose: If you plan to run multiple containers frequently, consider using Docker Compose. It allows you to define and manage multi-container Docker applications.
Data Persistence: If your applications need to store data, consider volume mapping to ensure data persistence outside of the container.
Manage Resources: Be mindful of your Droplet’s resources (CPU, memory). Running multiple applications, especially on a small droplet, can consume resources quickly.
The main benefit again is that each application runs in its isolated environment, ensuring that dependencies and configurations don’t conflict.
Hope that this helps!
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.