Docker installation

Tip

If you intend to create a public instance using Docker, use our well maintained searxng-docker image which includes

Make sure you have installed Docker and on Linux, don’t forget to add your user to the docker group (log out and log back in so that your group membership is re-evaluated):

$ sudo usermod -a -G docker $USER

searxng/searxng

The docker image is based on git://Dockerfile and available from searxng/searxng @dockerhub. Using the docker image is quite easy, for instance you can pull the searxng/searxng @dockerhub image and deploy a local instance using docker run:

$ mkdir my-instance
$ cd my-instance
$ export PORT=8080
$ docker pull searxng/searxng
$ docker run --rm \
             -d -p ${PORT}:8080 \
             -v "${PWD}/searx:/etc/searx" \
             -e "BASE_URL=http://localhost:$PORT/" \
             -e "INSTANCE_NAME=my-instance" \
             searxng/searxng
2f998.... # container's ID

Open your WEB browser and visit the URL:

$ xdg-open "http://localhost:$PORT"

Inside ${PWD}/searx, you will find settings.yml and uwsgi.ini. You can modify these files according to your needs and restart the Docker image.

$ docker container restart 2f998

Use command container ls to list running containers, add flag -a to list exited containers also. With container stop a running container can be stoped. To get rid of a container use container rm:

$ docker container ls
CONTAINER ID   IMAGE             COMMAND                  CREATED         ...
2f998d725993   searxng/searxng   "/sbin/tini -- /usr/…"   7 minutes ago   ...

$ docker container stop 2f998
$ docker container rm 2f998

If you won’t use docker anymore and want to get rid of all conatiners & images use the following prune command:

$ docker stop $(docker ps -aq)       # stop all containers
$ docker system prune                # make some housekeeping
$ docker rmi -f $(docker images -q)  # drop all images

shell inside container

Like in many other distributions, Alpine’s /bin/sh is dash. Dash is meant to be POSIX-compliant. Compared to debian, in the Alpine image bash is not installed. The git://dockerfiles/docker-entrypoint.sh script is checked against dash (make tests.shell).

To open a shell inside the container:

$ docker exec -it 2f998 sh

Build the image

It’s also possible to build SearXNG from the embedded git://Dockerfile:

$ git clone https://github.com/searxng/searxng.git
$ cd searx
$ make docker.build
...
Successfully built 49586c016434
Successfully tagged searxng/searxng:latest
Successfully tagged searxng/searxng:1.0.0-209-9c823800-dirty

$ docker images
REPOSITORY        TAG                        IMAGE ID       CREATED          SIZE
searxng/searxng   1.0.0-209-9c823800-dirty   49586c016434   13 minutes ago   308MB
searxng/searxng   latest                     49586c016434   13 minutes ago   308MB
alpine            3.13                       6dbb9cc54074   3 weeks ago      5.61MB

Command line

In the git://Dockerfile the ENTRYPOINT is defined as git://dockerfiles/docker-entrypoint.sh

docker run --rm -it searxng/searxng -h
Command line:
  -h  Display this help
  -d  Dry run to update the configuration files.
  -f  Always update on the configuration files (existing files are renamed with
      the .old suffix).  Without this option, the new configuration files are
      copied with the .new suffix
Environment variables:
  INSTANCE_NAME settings.yml : general.instance_name
  AUTOCOMPLETE  settings.yml : search.autocomplete
  BASE_URL      settings.yml : server.base_url
  MORTY_URL     settings.yml : result_proxy.url
  MORTY_KEY     settings.yml : result_proxy.key
  BIND_ADDRESS  uwsgi bind to the specified TCP socket using HTTP protocol.
                Default value: 0.0.0.0:8080
Volume:
  /etc/searx    the docker entry point copies settings.yml and uwsgi.ini in
                this directory (see the -f command line option)"