This guide provides a full Ansible playbook to deploy IBM WebSphere Liberty using Docker Compose.
It targets enterprise Linux deployments where IBM Container Registry access is available.
- name: Install IBM WebSphere Liberty with Docker
hosts: ibm-websphere
become: true
vars:
websphere_project_dir: /opt/ibm-websphere
liberty_image: "icr.io/appcafe/websphere-liberty:24.0.0.3-full-java17"
liberty_container_name: websphere-liberty
liberty_host_http_port: 8080
liberty_container_http_port: 8080
liberty_host_https_port: 9443
liberty_container_https_port: 9443
liberty_config_dir: "{{ websphere_project_dir }}/config"
liberty_apps_dir: "{{ websphere_project_dir }}/apps"
liberty_logs_dir: "{{ websphere_project_dir }}/logs"
liberty_wlp_output_dir: "{{ websphere_project_dir }}/wlp-output"
tasks:
- name: Install Docker prerequisites on RHEL family
dnf:
name:
- dnf-utils
state: present
when: ansible_os_family == "RedHat"
- 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 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 WebSphere project directory
file:
path: "{{ websphere_project_dir }}"
state: directory
mode: "0755"
- name: Create Liberty config directory
file:
path: "{{ liberty_config_dir }}"
state: directory
mode: "0755"
- name: Create Liberty apps directory
file:
path: "{{ liberty_apps_dir }}"
state: directory
mode: "0755"
- name: Create Liberty logs directory
file:
path: "{{ liberty_logs_dir }}"
state: directory
mode: "0755"
- name: Create Liberty wlp-output directory
file:
path: "{{ liberty_wlp_output_dir }}"
state: directory
mode: "0755"
- name: Create Docker Compose file
copy:
dest: "{{ websphere_project_dir }}/compose.yml"
mode: "0644"
content: |
services:
websphere-liberty:
image: {{ liberty_image }}
container_name: {{ liberty_container_name }}
ports:
- "{{ liberty_host_http_port }}:{{ liberty_container_http_port }}"
- "{{ liberty_host_https_port }}:{{ liberty_container_https_port }}"
volumes:
- {{ liberty_config_dir }}:/config
- {{ liberty_apps_dir }}:/dropins
- {{ liberty_logs_dir }}:/logs
- {{ liberty_wlp_output_dir }}:/wlp/output
restart: unless-stopped
environment:
- TZ=UTC
- LICENSE=accept
- name: Start IBM WebSphere Liberty container
community.docker.docker_compose_v2:
project_src: "{{ websphere_project_dir }}"
state: present
- name: Verify container is running
community.docker.docker_container_info:
name: "{{ liberty_container_name }}"
register: liberty_container_info
retries: 5
delay: 3
until: liberty_container_info.exists == true
LICENSE=accept environment variable is required to run WebSphere Liberty containers.latest.After deployment, access WebSphere Liberty at:
http://SERVER_IP:8080
HTTPS endpoint:
https://SERVER_IP:9443
Copy your WAR/EAR files to the dropins directory for automatic deployment:
sudo cp your-app.war /opt/ibm-websphere/apps/
Add server configuration files to the config directory:
sudo cp server.xml /opt/ibm-websphere/config/
docker logs websphere-liberty
# or
tail -f /opt/ibm-websphere/logs/messages.log
cd /opt/ibm-websphere
docker compose stop
docker compose start
Any questions?
Feel free to contact us. Find all contact information on our contact page.