2025-07-04 14:35:28 +02:00
|
|
|
.. _installation container:
|
2020-03-02 19:00:19 +01:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
======================
|
|
|
|
|
Installation container
|
|
|
|
|
======================
|
2020-03-02 19:00:19 +01:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
.. _Docker 101: https://docs.docker.com/get-started/docker-overview
|
|
|
|
|
.. _Docker cheat sheet (PDF doc): https://docs.docker.com/get-started/docker_cheatsheet.pdf
|
|
|
|
|
.. _Podman rootless containers: https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md
|
|
|
|
|
.. _DockerHub mirror: https://hub.docker.com/r/searxng/searxng
|
|
|
|
|
.. _GHCR mirror: https://ghcr.io/searxng/searxng
|
2021-04-29 14:33:35 +02:00
|
|
|
|
|
|
|
|
.. sidebar:: info
|
2020-03-02 19:00:19 +01:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
- `Docker 101`_
|
|
|
|
|
- `Docker cheat sheet (PDF doc)`_
|
|
|
|
|
- `Podman rootless containers`_
|
2022-06-14 10:02:50 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
.. important::
|
2022-06-14 10:02:50 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
Understanding container architecture basics is essential for properly
|
|
|
|
|
maintaining your SearXNG instance. This guide assumes familiarity with
|
|
|
|
|
container concepts and provides deployment steps at a high level.
|
2022-06-14 10:02:50 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
If you're new to containers, we recommend learning the fundamentals at
|
|
|
|
|
`Docker 101`_ before proceeding.
|
2022-06-14 10:02:50 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
Container images are the basis for deployments in containerized environments,
|
2026-03-28 16:45:06 +01:00
|
|
|
Compose, Kubernetes and more.
|
2022-06-14 10:02:50 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
.. _Container installation:
|
2022-06-14 10:02:50 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
Installation
|
|
|
|
|
============
|
2022-06-14 10:02:50 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
.. _Container prerequisites:
|
2022-06-14 10:02:50 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
Prerequisites
|
|
|
|
|
-------------
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
You need a working Docker or Podman installation on your system. Choose the
|
|
|
|
|
option that works best for your environment:
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
- `Docker <https://docs.docker.com/get-docker/>`_ (recommended for most users)
|
|
|
|
|
- `Podman <https://podman.io/docs/installation>`_
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
In the case of Docker, you need to add the user running the container to the
|
|
|
|
|
``docker`` group and restart the session:
|
2020-03-02 19:00:19 +01:00
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
$ sudo usermod -aG docker $USER
|
2020-03-02 19:00:19 +01:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
In the case of Podman, no additional steps are generally required, but there
|
|
|
|
|
are some considerations when running `Podman rootless containers`_.
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2026-03-28 16:45:06 +01:00
|
|
|
.. _Container registries:
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2026-03-28 16:45:06 +01:00
|
|
|
Registries
|
|
|
|
|
----------
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
.. note::
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
DockerHub now applies rate limits to unauthenticated image pulls. If you
|
|
|
|
|
are affected by this, you can use the `GHCR mirror`_ instead.
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
The official images are mirrored at:
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
- `DockerHub mirror`_
|
|
|
|
|
- `GHCR mirror`_ (GitHub Container Registry)
|
2023-11-12 17:46:34 +01:00
|
|
|
|
2026-03-28 16:45:06 +01:00
|
|
|
.. _Container compose instancing:
|
|
|
|
|
|
|
|
|
|
Compose instancing
|
|
|
|
|
==================
|
|
|
|
|
|
|
|
|
|
This is the recommended way to deploy SearXNG in a containerized environment.
|
|
|
|
|
Compose templates allow you to define container configurations in a
|
|
|
|
|
declarative manner.
|
|
|
|
|
|
|
|
|
|
.. _Container compose instancing setup:
|
|
|
|
|
|
|
|
|
|
Setup
|
|
|
|
|
-----
|
|
|
|
|
|
|
|
|
|
1. Create the environment:
|
|
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
|
|
# Create the environment and configuration directories
|
|
|
|
|
$ mkdir -p ./searxng/core-config/
|
|
|
|
|
$ cd ./searxng/
|
|
|
|
|
|
|
|
|
|
# Fetch the latest compose template
|
2026-04-04 21:57:32 +02:00
|
|
|
$ curl -fsSL \
|
|
|
|
|
-O https://raw.githubusercontent.com/searxng/searxng/master/container/docker-compose.yml \
|
|
|
|
|
-O https://raw.githubusercontent.com/searxng/searxng/master/container/.env.example
|
|
|
|
|
|
|
|
|
|
2. Copy the ``.env.example`` file and edit the values as needed:
|
2026-03-28 16:45:06 +01:00
|
|
|
|
2026-04-04 21:57:32 +02:00
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
|
|
$ cp -i .env.example .env
|
|
|
|
|
|
|
|
|
|
# nano or your preferred text editor...
|
|
|
|
|
$ nano .env
|
2026-03-28 16:45:06 +01:00
|
|
|
|
|
|
|
|
3. Start & stop the services:
|
|
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
|
|
$ docker compose up -d
|
|
|
|
|
$ docker compose down
|
|
|
|
|
|
|
|
|
|
4. Setup your settings in ``core-config/settings.yml`` according to your preferences.
|
|
|
|
|
|
|
|
|
|
.. _Container compose instancing maintenance:
|
|
|
|
|
|
|
|
|
|
Management
|
|
|
|
|
----------
|
|
|
|
|
|
|
|
|
|
.. important::
|
|
|
|
|
|
|
|
|
|
Remember to review the new templates for any changes that may affect your
|
|
|
|
|
deployment, and update the ``.env`` file accordingly.
|
|
|
|
|
|
|
|
|
|
To update the templates to their latest versions:
|
|
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
|
|
$ docker compose down
|
|
|
|
|
$ curl -fsSLO \
|
|
|
|
|
https://raw.githubusercontent.com/searxng/searxng/master/container/docker-compose.yml \
|
|
|
|
|
https://raw.githubusercontent.com/searxng/searxng/master/container/.env.example
|
|
|
|
|
$ docker compose up -d
|
|
|
|
|
|
|
|
|
|
To update the services to their latest versions:
|
|
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
|
|
$ docker compose down
|
|
|
|
|
$ docker compose pull
|
|
|
|
|
$ docker compose up -d
|
|
|
|
|
|
|
|
|
|
List running services:
|
|
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
|
|
$ docker compose ps
|
|
|
|
|
NAME IMAGE ... CREATED STATUS PORTS
|
|
|
|
|
searxng-core ... ... 3 minutes ago Up 3 minutes 0.0.0.0:8080->8080/tcp
|
|
|
|
|
searxng-valkey ... ... 3 minutes ago Up 3 minutes 6379/tcp
|
|
|
|
|
|
|
|
|
|
Print a service container logs:
|
|
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
|
|
$ docker compose logs -f core
|
|
|
|
|
|
|
|
|
|
Access a service container shell (troubleshooting):
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2021-04-29 14:33:35 +02:00
|
|
|
.. code:: sh
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2026-03-28 16:45:06 +01:00
|
|
|
$ docker compose exec -it --user root core /bin/sh -l
|
|
|
|
|
/usr/local/searxng #
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2026-03-28 16:45:06 +01:00
|
|
|
Stop and remove the services:
|
2021-04-29 14:33:35 +02:00
|
|
|
|
|
|
|
|
.. code:: sh
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2026-03-28 16:45:06 +01:00
|
|
|
$ docker compose down
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2026-03-28 16:45:06 +01:00
|
|
|
.. _Container manual instancing:
|
2025-07-04 14:35:28 +02:00
|
|
|
|
2026-03-28 16:45:06 +01:00
|
|
|
Manual instancing
|
|
|
|
|
=================
|
2025-07-04 14:35:28 +02:00
|
|
|
|
|
|
|
|
This section is intended for advanced users who need custom deployments. We
|
2026-03-28 16:45:06 +01:00
|
|
|
recommend using `Container compose instancing`_, which provides a preconfigured
|
|
|
|
|
environment with sensible defaults.
|
2025-07-04 14:35:28 +02:00
|
|
|
|
|
|
|
|
Basic container instancing example:
|
2020-03-02 19:00:19 +01:00
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
# Create directories for configuration and persistent data
|
|
|
|
|
$ mkdir -p ./searxng/config/ ./searxng/data/
|
|
|
|
|
$ cd ./searxng/
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
# Run the container
|
2025-10-10 21:31:48 +03:00
|
|
|
$ docker run --name searxng -d \
|
2025-07-04 14:35:28 +02:00
|
|
|
-p 8888:8080 \
|
|
|
|
|
-v "./config/:/etc/searxng/" \
|
|
|
|
|
-v "./data/:/var/cache/searxng/" \
|
|
|
|
|
docker.io/searxng/searxng:latest
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
This will start SearXNG in the background, accessible at http://localhost:8888
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
.. _Container management:
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
Management
|
|
|
|
|
----------
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
List running containers:
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
.. code:: sh
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
$ docker container list
|
|
|
|
|
CONTAINER ID IMAGE ... CREATED PORTS NAMES
|
[enh] container: tidy builds (#5086)
Building the container currently does not work properly.
When rebuilding several times with `make container`, `version_frozen.py`
is recreated, which wouldn't be an issue if the file’s timestamp was constant.
Now, when creating `version_frozen.py`, it will have the same timestamp as the
commit when it was created. (`version_frozen.py` is moved to a dedicated layer).
Reusing "builder" cache when building "dist" could be slow
(CD reports 2 seconds, but locally I've seen it take up to 10 seconds),
so the Dockerfile is now split and we save a couple steps
by importing the "builder" image directly.
The last changes made it possible to remove the layer cache in "builder",
since the overhead is now greater than building the layers from scratch.
Until now, all "dist" layers were squashed into a single layer,
which in most cases is a good idea
(except for storage/delivery pricing/overhead), but in our case,
since we manage the entire pipeline, we can ignore this
and share layers between builds.
This means (for example) that if we change files unrelated to the container
in several consecutive commits (documentation changes), we don't have to push
the entire image to registry, but only the different layers
(`version_frozen.py` in this example).
The same applies when pulling, as only the layers that have changed
compared to the local layers will be downloaded (that's the theory,
we'll see if this works as expected or if we need to tweak something else).
2025-08-07 10:46:26 +02:00
|
|
|
1af574997e63 ... ... 3 minutes ago 0.0.0.0:8888->8080/tcp searxng
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2026-03-28 16:45:06 +01:00
|
|
|
Print the container logs:
|
|
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
|
|
$ docker container logs -f searxng
|
|
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
Access the container shell (troubleshooting):
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
.. code:: sh
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
$ docker container exec -it --user root searxng /bin/sh -l
|
2026-03-28 16:45:06 +01:00
|
|
|
/usr/local/searxng #
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
Stop and remove the container:
|
2021-04-29 14:33:35 +02:00
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
$ docker container stop searxng
|
|
|
|
|
$ docker container rm searxng
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
.. _Container volumes:
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
Volumes
|
|
|
|
|
=======
|
2020-07-22 14:58:04 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
Two volumes are exposed that should be mounted to preserve its contents:
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
- ``/etc/searxng``: Configuration files (settings.yml, etc.)
|
|
|
|
|
- ``/var/cache/searxng``: Persistent data (faviconcache.db, etc.)
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
.. _Container environment variables:
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
Environment variables
|
|
|
|
|
=====================
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
The following environment variables can be configured:
|
|
|
|
|
|
|
|
|
|
- ``$SEARXNG_*``: Controls the SearXNG configuration options, look out for
|
2026-03-28 16:45:06 +01:00
|
|
|
environment ``$SEARXNG_*`` in :ref:`settings server`, :ref:`settings
|
|
|
|
|
general` and the :origin:`container/.env.example` template.
|
2025-07-04 14:35:28 +02:00
|
|
|
- ``$GRANIAN_*``: Controls the :ref:`Granian server options <Granian configuration>`.
|
|
|
|
|
- ``$FORCE_OWNERSHIP``: Ensures mounted volumes/files are owned by the
|
|
|
|
|
``searxng:searxng`` user (default: ``true``)
|
|
|
|
|
|
2025-09-23 21:57:29 +02:00
|
|
|
.. _Container custom certificates:
|
|
|
|
|
|
|
|
|
|
Custom certificates
|
|
|
|
|
===================
|
|
|
|
|
|
|
|
|
|
You can mount ``/usr/local/share/ca-certificates/`` folder to add/remove
|
|
|
|
|
additional certificates as needed.
|
|
|
|
|
|
|
|
|
|
They will be available on container (re)start or when running
|
|
|
|
|
``update-ca-certificates`` in the container shell.
|
|
|
|
|
|
2026-03-28 16:45:06 +01:00
|
|
|
This requires the container to be running with ``root`` privileges.
|
|
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
.. _Container custom images:
|
2021-04-29 14:33:35 +02:00
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
Custom images
|
|
|
|
|
=============
|
|
|
|
|
|
|
|
|
|
To build your own SearXNG container image from source (please note, custom
|
|
|
|
|
container images are not officially supported):
|
2021-04-29 14:33:35 +02:00
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
2025-07-04 14:35:28 +02:00
|
|
|
$ git clone https://github.com/searxng/searxng.git
|
|
|
|
|
$ cd ./searxng/
|
|
|
|
|
|
|
|
|
|
# Run the container build script
|
|
|
|
|
$ make container
|
|
|
|
|
|
|
|
|
|
$ docker images
|
[enh] container: tidy builds (#5086)
Building the container currently does not work properly.
When rebuilding several times with `make container`, `version_frozen.py`
is recreated, which wouldn't be an issue if the file’s timestamp was constant.
Now, when creating `version_frozen.py`, it will have the same timestamp as the
commit when it was created. (`version_frozen.py` is moved to a dedicated layer).
Reusing "builder" cache when building "dist" could be slow
(CD reports 2 seconds, but locally I've seen it take up to 10 seconds),
so the Dockerfile is now split and we save a couple steps
by importing the "builder" image directly.
The last changes made it possible to remove the layer cache in "builder",
since the overhead is now greater than building the layers from scratch.
Until now, all "dist" layers were squashed into a single layer,
which in most cases is a good idea
(except for storage/delivery pricing/overhead), but in our case,
since we manage the entire pipeline, we can ignore this
and share layers between builds.
This means (for example) that if we change files unrelated to the container
in several consecutive commits (documentation changes), we don't have to push
the entire image to registry, but only the different layers
(`version_frozen.py` in this example).
The same applies when pulling, as only the layers that have changed
compared to the local layers will be downloaded (that's the theory,
we'll see if this works as expected or if we need to tweak something else).
2025-08-07 10:46:26 +02:00
|
|
|
REPOSITORY TAG IMAGE ID CREATED SIZE
|
|
|
|
|
localhost/searxng/searxng 2025.8.1-3d96414 ... About a minute ago 183 MB
|
|
|
|
|
localhost/searxng/searxng latest ... About a minute ago 183 MB
|
|
|
|
|
localhost/searxng/searxng builder ... About a minute ago 524 MB
|
|
|
|
|
ghcr.io/searxng/base searxng-builder ... 2 days ago 378 MB
|
|
|
|
|
ghcr.io/searxng/base searxng ... 2 days ago 42.2 MB
|
2026-03-28 16:45:06 +01:00
|
|
|
|
|
|
|
|
Migrate from ``searxng-docker``
|
|
|
|
|
===============================
|
|
|
|
|
|
|
|
|
|
We expect the following source directory structure:
|
|
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
|
|
.
|
|
|
|
|
└── searxng-docker
|
|
|
|
|
├── searxng
|
|
|
|
|
│ ├── favicons.toml
|
|
|
|
|
│ ├── limiter.toml
|
|
|
|
|
│ ├── settings.yml
|
|
|
|
|
│ └── ...
|
|
|
|
|
├── .env
|
|
|
|
|
├── Caddyfile
|
|
|
|
|
├── docker-compose.yml
|
|
|
|
|
└── ...
|
|
|
|
|
|
|
|
|
|
Create a brand new environment outside ``searxng-docker`` directory, following
|
|
|
|
|
`Container compose instancing setup`_.
|
|
|
|
|
|
|
|
|
|
Once up and running, stop the services and move the configuration files from
|
|
|
|
|
the old mount to the new one:
|
|
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
|
|
$ mv ./searxng-docker/searxng/* ./searxng/core-config/
|
|
|
|
|
|
2026-04-04 21:57:32 +02:00
|
|
|
If using Valkey features like bot protection (limiter), you will need to update
|
|
|
|
|
the URL hostname in :origin:`searx/settings.yml` file to ``valkey`` or
|
|
|
|
|
``searxng-valkey``.
|
|
|
|
|
|
|
|
|
|
If you have any environment variables in the old ``.env`` file, make
|
|
|
|
|
sure to add them to the new one.
|
2026-03-28 16:45:06 +01:00
|
|
|
|
|
|
|
|
Consider setting up a reverse proxy if exposing the instance to the public.
|
|
|
|
|
|
|
|
|
|
You should end with the following directory structure:
|
|
|
|
|
|
|
|
|
|
.. code:: sh
|
|
|
|
|
|
|
|
|
|
.
|
|
|
|
|
├── searxng
|
|
|
|
|
│ ├── core-config
|
|
|
|
|
│ │ ├── favicons.toml
|
|
|
|
|
│ │ ├── limiter.toml
|
|
|
|
|
│ │ ├── settings.yml
|
|
|
|
|
│ │ └── ...
|
|
|
|
|
│ ├── .env.example
|
|
|
|
|
│ ├── .env
|
|
|
|
|
│ └── docker-compose.yml
|
|
|
|
|
└── searxng-docker
|
|
|
|
|
└── ...
|
|
|
|
|
|
|
|
|
|
If everything is working on the new environment, you can remove the old
|
|
|
|
|
``searxng-docker`` directory and its contents.
|