When Docker is the right choice
Use Docker when you already build images, when your application needs native libraries or a specific JDK build, or when you want the same artifact in CI, staging and production. On a single VPS, Docker Compose is the simple way to run it, without the overhead of Kubernetes.
How it works on our server
- Docker Engine and the Compose plugin installed from the official repository.
- Your container runs from
/opt/docker-app/compose.yamland restarts automatically. - Nginx terminates HTTPS and proxies to the container on localhost.
- Update with
sudo deploy-app registry/image:tag. It pulls the image and recreates the container. - Private registries work. Log in once with
docker loginand the credentials stay on your server.
Container memory and the JVM
Modern JVMs read the container memory limit. Use -XX:MaxRAMPercentage=60 instead of a fixed -Xmx so the heap follows the limit. Set an explicit memory limit on the container, otherwise a leak can consume the whole server. Leave room for metaspace, thread stacks and native memory: the heap is not the whole process.
services:
app:
image: registry.example.com/myapp:1.4.2
restart: unless-stopped
network_mode: host
mem_limit: 3g
environment:
JAVA_TOOL_OPTIONS: "-XX:MaxRAMPercentage=60"
SERVER_PORT: "8080"
Databases in containers
You can run your database in Docker too, or install MySQL, MariaDB or PostgreSQL directly on the server for simpler backups. We can set up either.
Questions about docker java hosting
Do you provide a registry?
No. Use Docker Hub, GitHub Container Registry or your own. Private registries work through docker login on your server.
Can I run Kubernetes?
A single VPS is a good fit for Docker Compose. For Kubernetes you need several servers and a different setup, so contact us.