This guide provides a full Ansible playbook to deploy Payara Server using Docker Compose.
It covers Debian 10 to latest stable, Ubuntu LTS releases, and RHEL 9+ compatible systems.
- name: Install Payara Server with Docker
hosts: payara
become: true
vars:
payara_project_dir: /opt/payara
payara_image: "payara/server-full:7.2026.2"
payara_container_name: payara
payara_host_http_port: 8080
payara_container_http_port: 8080
payara_host_admin_port: 4848
payara_container_admin_port: 4848
payara_config_dir: "{{ payara_project_dir }}/config"
payara_domains_dir: "{{ payara_project_dir }}/domains"
payara_logs_dir: "{{ payara_project_dir }}/logs"
tasks:
- name: Install Docker prerequisites on Debian/Ubuntu
apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- lsb-release
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install Docker prerequisites on RHEL family
dnf:
name:
- dnf-utils
state: present
when: ansible_os_family == "RedHat"
- name: Add Docker GPG key on Debian/Ubuntu
apt_key:
url: https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg
state: present
when: ansible_os_family == "Debian"
- name: Add Docker repository on Debian/Ubuntu
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
state: present
when: ansible_os_family == "Debian"
- name: Add Docker repository on RHEL family
yum_repository:
name: docker-ce
description: Docker CE Repository
baseurl: "https://download.docker.com/linux/centos/$releasever/$basearch/stable"
gpgcheck: yes
gpgkey: https://download.docker.com/linux/centos/gpg
when: ansible_os_family == "RedHat"
- name: Install Docker packages on Debian/Ubuntu
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose-plugin
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install Docker packages on RHEL family
dnf:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose-plugin
state: present
when: ansible_os_family == "RedHat"
- name: Enable and start Docker service
systemd:
name: docker
state: started
enabled: true
- name: Create Payara project directory
file:
path: "{{ payara_project_dir }}"
state: directory
mode: "0755"
- name: Create Payara config directory
file:
path: "{{ payara_config_dir }}"
state: directory
mode: "0755"
- name: Create Payara domains directory
file:
path: "{{ payara_domains_dir }}"
state: directory
mode: "0755"
- name: Create Payara logs directory
file:
path: "{{ payara_logs_dir }}"
state: directory
mode: "0755"
- name: Create Docker Compose file
copy:
dest: "{{ payara_project_dir }}/compose.yml"
mode: "0644"
content: |
services:
payara:
image: {{ payara_image }}
container_name: {{ payara_container_name }}
ports:
- "{{ payara_host_http_port }}:{{ payara_container_http_port }}"
- "{{ payara_host_admin_port }}:{{ payara_container_admin_port }}"
volumes:
- {{ payara_config_dir }}:/opt/payara/config
- {{ payara_domains_dir }}:/opt/payara/domains
- {{ payara_logs_dir }}:/opt/payara/logs
restart: unless-stopped
environment:
- TZ=UTC
- name: Start Payara container
community.docker.docker_compose_v2:
project_src: "{{ payara_project_dir }}"
state: present
- name: Verify container is running
community.docker.docker_container_info:
name: "{{ payara_container_name }}"
register: payara_container_info
retries: 5
delay: 3
until: payara_container_info.exists == true
latest.After deployment, access Payara Server at:
http://SERVER_IP:8080
Admin console:
http://SERVER_IP:4848
Use the admin console or asadmin CLI to deploy applications:
docker exec payara /opt/payara/bin/asadmin deploy /path/to/your-app.war
docker logs payara
# or
tail -f /opt/payara/logs/server.log
cd /opt/payara
docker compose stop
docker compose start
Any questions?
Feel free to contact us. Find all contact information on our contact page.