This guide deploys LocalAI with Docker Compose on Debian 10 to latest stable, Ubuntu LTS, and RHEL 9+ compatible hosts.
- name: Deploy LocalAI
hosts: localai
become: true
vars:
app_root: /opt/localai
app_port: 8080
tasks:
- name: Install Docker on Debian/Ubuntu
apt:
name:
- docker.io
- docker-compose-plugin
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install Docker on RHEL family
dnf:
name:
- docker
- docker-compose-plugin
state: present
when: ansible_os_family == "RedHat"
- name: Enable and start Docker
service:
name: docker
state: started
enabled: true
- name: Create app directory
file:
path: "{{ app_root }}"
state: directory
mode: "0755"
- name: Write Docker Compose file
copy:
dest: "{{ app_root }}/docker-compose.yml"
mode: "0644"
content: |
services:
localai:
image: localai/localai:latest
restart: unless-stopped
ports:
- "{{ app_port }}:8080"
volumes:
- ./models:/models
- name: Start application stack
command: docker compose up -d
args:
chdir: "{{ app_root }}"
localai/localai:latest-gpu-nvidia-cuda-12 or other GPU variants.localai for consistency with other LocalAI documentation.Any questions?
Feel free to contact us. Find all contact information on our contact page.