How to Deploy a Java Web App to Cube with Docker: Step‑by‑Step Guide
This tutorial walks you through turning a Java cloud‑gaming demo into a Docker image, publishing it to Uhub, and running it on Cube, covering Docker basics, environment setup, Dockerfile creation, image build and push, and next steps for CI/CD integration.
The video demonstrates a typical Java application (a cloud‑gaming demo) and explains how to package it into a Docker image and run it on Cube.
Key Steps
Understand Docker basics
Prepare the environment
Apply for a Uhub account and create an image repository.
Set up Java build tools and Docker, then log in to Uhub.
Prepare the Dockerfile
FROM uhub.service.ucloud.cn/hello/maven:3-jdk-8-alpine
WORKDIR /usr/src/app
# Replace with your own jar/war filename
COPY target/cloudgame-0.0.1-SNAPSHOT.war /usr/src/app
# Open port if exposing externally (adjust firewall)
ENV PORT 8080
EXPOSE $PORT
# Adjust memory as needed (slightly less than Cube limit)
CMD [ "sh", "-c", "java -Xmx3072M -jar /usr/src/app/cloudgame-0.0.1-SNAPSHOT.war -Dserver.port=${PORT}" ]Build the Docker image and push to Uhub
docker build -t uhub.service.ucloud.cn/gary/cloudgame-image:mytag .
docker push uhub.service.ucloud.cn/gary/cloudgame-image:mytagNext steps
Continue improving the image.
Integrate it into a CI/CD pipeline for automated deployment.
If you encounter any issues during the process, feel free to leave a comment for discussion.
UCloud Tech
UCloud is a leading neutral cloud provider in China, developing its own IaaS, PaaS, AI service platform, and big data exchange platform, and delivering comprehensive industry solutions for public, private, hybrid, and dedicated clouds.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
