A self-hosted AI application needs its documents and settings to outlive the container that serves it. AnythingLLM can run on a Linux host as a Docker Compose service with a reusable definition and persistent storage, leaving its web interface available on port 3001.
Docker Compose keeps the image, port mapping, storage mounts, and restart policy in one file. The prebuilt image from Mintplex Labs avoids a source build, while a fixed release tag keeps a later start from silently switching to a daily build.
A fresh instance opens at the AnythingLLM welcome screen. Chat still needs a configured model provider; starting the web application does not download a model or enable the built-in inference engine.
The shell commands use a Linux Docker host with Docker Engine and the Compose plugin already installed, plus permission to run docker. Docker access grants control equivalent to root on that host. The project and storage directories below must be new, and port 3001 must be free. A new installation has no access protection configured, so keep the host on a trusted private network during setup.
Steps to run AnythingLLM with Docker Compose:
- Create a new Compose project directory in your home folder.
$ mkdir "$HOME/anythingllm-compose"
Ubuntu prerequisites are covered by Docker's installation instructions and the Compose plugin installation instructions.
- Change to the Compose project directory.
$ cd "$HOME/anythingllm-compose"
Subsequent docker compose commands run here so they use the same compose.yaml.
- Create the persistent AnythingLLM storage directory.
$ mkdir "$HOME/anythingllm"
- Create an empty application environment file in the storage directory.
$ touch "$HOME/anythingllm/.env"
AnythingLLM writes configuration to this file. Mounting it separately at /app/server/.env preserves those settings when Compose replaces the container. It is distinct from a project-level .env used for Compose interpolation.
- Restrict the environment file to its owner.
$ chmod 600 "$HOME/anythingllm/.env"
The file can contain provider keys after configuration, so it must not be shared or committed to a repository.
- Give the new storage directory to the container's user.
$ sudo chown -R 1000:1000 "$HOME/anythingllm"
The prebuilt image runs as UID/GID 1000:1000. This changes ownership only inside the new storage directory so the application can write its database and configuration, even when your Linux user has another UID. It does not grant every local user write access.
- Create a file named compose.yaml in anythingllm-compose using your text editor.
- compose.yaml
name: anythingllm services: anythingllm: image: mintplexlabs/anythingllm:1.19.0 container_name: anythingllm restart: unless-stopped ports: - "3001:3001" environment: STORAGE_DIR: /app/server/storage volumes: - ${HOME}/anythingllm:/app/server/storage - ${HOME}/anythingllm/.env:/app/server/.env cpus: 2 mem_limit: 4g
The file uses release 1.19.0 of the official image. Compose expands ${HOME} to your home directory; STORAGE_DIR names the path inside the container. The two mounts follow AnythingLLM's persistent-storage requirements. The limits allow up to two CPUs and 4 GiB of memory for the web application; model inference has separate resource needs.
The port mapping publishes port 3001 on every host interface. Anyone who can reach that port can open the application before access controls are configured. Internet exposure needs authentication and HTTPS protection. This basic web service uses Docker's default capabilities; it does not add the broad SYS_ADMIN capability used by upstream browser automation examples.
- Save compose.yaml in your text editor.
- Validate the Compose definition.
$ docker compose config --quiet
A valid file produces no output. An error must be fixed before starting the service.
- Pull the AnythingLLM image declared in the Compose file.
$ docker compose pull
- Start the AnythingLLM service in the background.
$ docker compose up -d
The restart policy starts the service again when Docker restarts unless it was explicitly stopped. Its initial database setup can take a short time.
- Confirm that Compose lists the AnythingLLM service as running. Example output:
$ docker compose ps --format 'table {{.Name}}\t{{.Service}}\t{{.State}}' NAME SERVICE STATE anythingllm anythingllm runningThe service must be running. A restarting or exited container needs investigation before browser access.
Related: How to view Docker logs for AnythingLLM - Confirm that the AnythingLLM welcome screen loads at http://localhost:3001 in your browser.
For a remote Docker host, replace localhost with that host's private IP address or hostname. The AnythingLLM Welcome screen and Get Started button show that the Compose-started web application is reachable. On an already configured instance, its home or sign-in screen appears instead.