Docs

Documentation versions (currently viewingVaadin 24)

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 which is a text document containing all the commands for assembling and running the 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 Vaadin application:

    mvn clean package -Pproduction
  2. Run the following command to build your container:

    docker build . -t myapp:latest
    Note
    The command assumes your project name is myapp; replace myapp with the name of your project if it’s not.
  3. run the following command to run your container on localhost:

    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 before you can run the above commands.

Adding a Dockerfile to Existing Vaadin Applications

The following example 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 shown earlier.

You can find more information on Dockerfile and the instructions that are available for it at https://docs.docker.com/engine/reference/builder/.

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