Documentation

Documentation versions (currently viewingVaadin 23)
New Acceleration Kits: Observability Kit, SSO Kit, and Swing Kit. Read the blog post.

Deploying Using Docker

Deploy your Vaadin application using Docker

A Docker container is a standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings. Building a Docker image requires creating a Dockerfile, a text document containing all the commands needed to assemble and run that image.

Creating a Dockerfile for New Vaadin Applications

For a new Vaadin application, you can generate a Dockerfile by selecting the Docker config option in https://start.vaadin.com, in the Settings tab. This approach makes building and running your container as simple as running the following commands:

  1. Run the following command to make a production build of the actual Vaadin application:

    mvn clean install -Pproduction
  2. Run the following command to build your container (assuming your project name is myapp):

    docker build . -t myapp:latest
  3. To run your container on localhost, run the following command:

    docker run -p 8080:8080 myapp:latest
Note
Docker Desktop or Docker Server is required
You need to install Docker Desktop or Docker Server on your machine first, before you can run the above commands.

Adding a Dockerfile to Existing Vaadin Applications

The following shows a suitable Dockerfile for Spring Boot-based Vaadin applications. You get a similar file when you download a project from https://start.vaadin.com.

FROM openjdk:17-jdk-slim
COPY target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app.jar"]

Once you have a Dockerfile in the project directory, you can build and run your container using the docker build and docker run commands given earlier.

You can find more information on Dockerfile and its available instructions at https://docs.docker.com/engine/reference/builder/.

08DE0256-3D68-4F05-9092-F8ACB1A16C64