Skip to content

Commit 2ec2241

Browse files
committed
edits
1 parent 26d4ba2 commit 2ec2241

File tree

2 files changed

+32
-33
lines changed

2 files changed

+32
-33
lines changed

articles/container-apps/TOC.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@
402402
displayName: java
403403
- name: Introduction to containers
404404
href: java-containers-intro.md
405+
displayName: java
405406
- name: Turn on Java features
406407
href: java-feature-switch.md
407408
displayName: java
@@ -410,7 +411,7 @@
410411
displayName: java
411412
- name: Build environment variables (preview)
412413
href: java-build-environment-variables.md
413-
displayName: java
414+
displayName: java
414415
- name: Launch your first Java app
415416
items:
416417
- name: Dockerfile
@@ -428,14 +429,13 @@
428429
- name: Artificial intelligence
429430
items:
430431
- name: PetClinic AI
431-
items:
432+
items:
432433
- name: Overview
433434
href: java-petclinic-ai-overview.md
434435
displayName: java
435436
- name: Deploy the PetClinic AI sample
436437
href: java-petclinic-ai-tutorial.md
437438
displayName: java
438-
displayName: java
439439
- name: Java components
440440
items:
441441
- name: Launch your first Java microservice apps with managed Java components
@@ -482,7 +482,7 @@
482482
href: java-dynamic-log-level.md
483483
displayName: java
484484
- name: JavaScript
485-
items:
485+
items:
486486
- name: Overview
487487
href: javascript-overview.md
488488
displayName: javascript, typescript, node.js

articles/container-apps/java-containers-intro.md

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: KarlErickson
55
ms.reviewer: craigshoemaker
66
ms.service: azure-container-apps
77
ms.topic: conceptual
8-
ms.date: 04/15/2025
8+
ms.date: 04/23/2025
99
ms.author: karler
1010
ms.custom: devx-track-java
1111
ai-usage: ai-generated
@@ -18,17 +18,17 @@ Containers provide a consistent, portable environment for your Java applications
1818
In this article, you learn essential containerization concepts for Java developers and the following skills:
1919

2020
- Setting up your development environment for containerized Java applications.
21-
- Creating **Dockerfiles** optimized for Java workloads.
21+
- Creating Dockerfiles optimized for Java workloads.
2222
- Configuring local development workflows with containers.
2323
- Debugging containerized Java applications.
2424
- Optimizing Java containers for production.
2525
- Deploying your containerized Java applications to Azure Container Apps.
2626

27-
By containerizing your Java applications, you get consistent environments, simplified deployments, efficient resource utilization, and improved scalability.
27+
By containerizing your Java applications, you get consistent environments, simplified deployment, efficient resource utilization, and improved scalability.
2828

2929
## Containers for Java applications
3030

31-
Containers package applications with their dependencies, ensuring consistency across environments. For Java developers, this means bundling the application, its dependencies, the Java Runtime Environment/Java Development Kit (JRE/JDK), and the configuration files into a single, portable unit.
31+
Containers package applications with their dependencies, ensuring consistency across environments. For Java developers, this means bundling the application, its dependencies, the Java Runtime Environment/Java Development Kit (JRE/JDK), and configuration files into a single, portable unit.
3232

3333
Containerization has key advantages over virtualization that makes it ideal for cloud development. In contrast to a virtual machine, a container runs on a server's host OS kernel. This is beneficial for Java applications, which already run in the Java virtual machine (JVM). Containerizing Java applications adds minimal overhead and provides significant deployment benefits.
3434

@@ -52,10 +52,9 @@ To containerize Java applications, you need the following tools installed on you
5252
- [Docker Desktop](https://www.docker.com/products/docker-desktop/). Provides the Docker engine, CLI, and Docker Compose for Windows or macOS.
5353
- [Visual Studio Code](https://code.visualstudio.com/download). Available as a free code editor.
5454
- The following Visual Studio Code extensions:
55-
56-
- [Docker extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker) for managing containers.
57-
- [Java Extension Pack](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack) for Java development.
58-
- [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) for developing inside containers.
55+
- [Docker extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker) for managing containers.
56+
- [Java Extension Pack](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack) for Java development.
57+
- [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) for developing inside containers.
5958

6059
Verify your installation by using the following commands:
6160

@@ -68,7 +67,7 @@ docker compose version
6867

6968
For Java development in containers, configure Visual Studio Code by installing the Java Extension Pack and setting up your JDK. The Dev Containers extension enables you to open any folder inside a container and use Visual Studio Code's full feature set inside that container.
7069

71-
Creating a **.devcontainer/devcontainer.json** file in your project enables Visual Studio Code to automatically build and connect to a development container.
70+
To enable Visual Studio Code to automatically build and connect to a development container, create a **.devcontainer/devcontainer.json** file in your project.
7271

7372
For instance, the following example configuration defines a Java build:
7473

@@ -95,10 +94,10 @@ This configuration uses Microsoft's Java development container image, adds essen
9594

9695
A **Dockerfile** contains instructions for building a Docker image. For Java applications, the **Dockerfile** typically includes the following components:
9796

98-
1. A base image with the JDK or JRE.
99-
1. Instructions to copy application files.
100-
1. Commands to set environment variables.
101-
1. Configurations of entry points.
97+
- A base image with the JDK or JRE.
98+
- Instructions to copy application files.
99+
- Commands to set environment variables.
100+
- Configurations of entry points.
102101

103102
### Select a base image
104103

@@ -127,7 +126,7 @@ EXPOSE 8080
127126
ENTRYPOINT ["java", "-jar", "app.jar"]
128127
```
129128

130-
For Spring Boot applications, you can set up your Dockerfile with the following base:
129+
For Spring Boot applications, you can set up your **Dockerfile** with the following base:
131130

132131
```dockerfile
133132
FROM mcr.microsoft.com/java/jdk:21-zulu-ubuntu
@@ -137,7 +136,7 @@ EXPOSE 8080
137136
ENTRYPOINT ["java", "-Dspring.profiles.active=docker", "-jar", "app.jar"]
138137
```
139138

140-
For production deployments, use the following JRE image to reduce the size and minimize the attack surface of your application:
139+
For production deployments, use the JRE image shown in the following example to reduce the size and minimize the attack surface of your application:
141140

142141
```dockerfile
143142
FROM mcr.microsoft.com/java/jre:21-zulu-ubuntu
@@ -164,7 +163,7 @@ Docker Compose is a tool that enables you to perform the following tasks:
164163
- Manage the application lifecycle, including start, stop, and rebuild.
165164
- Maintain isolated environments.
166165
- Create networks for service communication.
167-
- Persists data using volumes.
166+
- Persist data using volumes.
168167

169168
#### Example: Java application with database
170169

@@ -244,12 +243,12 @@ A typical Java development workflow using Docker Compose contains the following
244243

245244
1. Create the **compose.yml** file and the **Dockerfile**.
246245
1. Run `docker compose up` to start all services.
247-
1. Make changes to your Java code,
246+
1. Make changes to your Java code.
248247
1. Rebuild your application. Depending on the configuration, you might need to restart your containers.
249248
1. Test the changes in the containerized environment.
250249
1. When you're finished, run `docker compose down`.
251250

252-
### Running single containers with Docker
251+
### Run single containers with Docker
253252

254253
For simpler scenarios when you don't need multiple interconnected services, you can use the `docker run` command to start individual containers.
255254

@@ -272,17 +271,17 @@ docker run -d -p 8080:8080 --name my-java-app myapp:latest
272271
docker run -p 8080:8080 -v ./data:/app/data myapp:latest
273272
```
274273

275-
## Debugging containerized applications
274+
## Debug containerized applications
276275

277276
Debugging containerized Java applications is sometimes challenging because your code runs in an isolated environment inside the container.
278277

279278
Standard debugging approaches don't always directly apply, but with the right configuration, you can establish a remote debugging connection to your application. This section shows you how to configure your containers for debugging, connect your development tools to running containers, and troubleshoot common container-related issues.
280279

281280
### Set up remote debugging
282281

283-
Debugging containerized Java applications requires exposing a debug port and configuring your IDE to connect to it by using the following steps:
282+
Debugging containerized Java applications requires exposing a debug port and configuring your IDE to connect to it. You can accomplish these tasks by using the following steps:
284283

285-
1. To enable debugging, modify your **Dockerfile** so it contains the following example:
284+
1. To enable debugging, modify your **Dockerfile** so it contains the following content:
286285

287286
> [!NOTE]
288287
> You can modify your container startup command, instead.
@@ -295,7 +294,7 @@ Debugging containerized Java applications requires exposing a debug port and con
295294
ENTRYPOINT ["java", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005", "-jar", "app.jar"]
296295
```
297296

298-
1. Configure Visual Studio Code's **launch.json** file to connect to the debug port by using the following example::
297+
1. Configure Visual Studio Code's **launch.json** file to connect to the debug port, as shown in the following example:
299298

300299
```json
301300
{
@@ -334,7 +333,7 @@ docker inspect <CONTAINER_ID>
334333
docker exec -it <CONTAINER_ID> bash
335334
```
336335

337-
For Java-specific issues, enable the JVM flags for better diagnostics by using the following example:
336+
For Java-specific issues, enable the JVM flags for better diagnostics, as shown in the following example:
338337

339338
```dockerfile
340339
ENTRYPOINT ["java", "-XX:+PrintFlagsFinal", "-XX:+PrintGCDetails", "-jar", "app.jar"]
@@ -351,15 +350,15 @@ The following table lists common issues and corresponding solutions:
351350

352351
## Optimize Java containers
353352

354-
Java applications in containers require special consideration for optimal performance. The JVM was designed before containers were common, which can lead to resource allocation issues if not properly configured.
353+
Java applications in containers require special consideration for optimal performance. The JVM was designed before containers were common. Using containers can lead to resource allocation issues if they aren't properly configured.
355354

356-
By fine-tuning memory settings, optimizing the image size, and configuring garbage collection, you can significantly improve the performance and efficiency of your containerized Java applications. This section covers essential optimizations for Java containers, with a focus on memory management, startup time, and resource utilization.
355+
You can significantly improve the performance and efficiency of your containerized Java applications by fine-tuning memory settings, optimizing the image size, and configuring garbage collection. This section covers essential optimizations for Java containers, with a focus on memory management, startup time, and resource utilization.
357356

358357
### JVM memory configuration in containers
359358

360359
The JVM doesn't automatically detect container memory limits in Java 8. For Java 9+, container awareness is enabled by default.
361360

362-
Configure your JVM to respect container limits by using the following example:
361+
Configure your JVM to respect container limits, as shown in the following example:
363362

364363
```dockerfile
365364
FROM mcr.microsoft.com/java/jre:21-zulu-ubuntu
@@ -387,7 +386,7 @@ This section covers the essential practices and configurations needed to prepare
387386

388387
Secure your containerized Java applications by using the following practices:
389388

390-
- Default security context. Run your applications as a non-root user by using the following example:
389+
- Default security context. Run your applications as a non-root user, as shown in the following example:
391390

392391
```dockerfile
393392
FROM mcr.microsoft.com/java/jre:21-zulu-ubuntu
@@ -413,7 +412,7 @@ Secure your containerized Java applications by using the following practices:
413412

414413
Check application health with [probes](health-probes.md) to ensure your application is running correctly.
415414

416-
For Spring Boot applications, include the Actuator dependency for comprehensive health endpoints by using the following XML example:
415+
For Spring Boot applications, include the Actuator dependency for comprehensive health endpoints, as shown in the following example:
417416

418417
```xml
419418
<dependency>
@@ -430,7 +429,7 @@ This section guides you through preparing your Java containers for Azure Contain
430429

431430
### Prepare your container for Azure
432431

433-
- Port configuration. Ensure your container listens on the port provided by Azure by using the following example:
432+
- Port configuration. Ensure your container listens on the port provided by Azure, as shown in the following example:
434433

435434
```dockerfile
436435
FROM mcr.microsoft.com/java/jre:21-zulu-ubuntu

0 commit comments

Comments
 (0)