searxng/docs/admin/installation-docker.rst
Markus Heiser ecb7e73e03 [brand] docs - normalize project name to SearXNG
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2021-09-13 14:36:24 +02:00

5.6 KiB

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

docker run

  • --rm automatically clean up when container exits
  • -d start detached container
  • -v mount volume HOST:CONTAINER

The docker image is based on 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

Warning

This might remove all docker items, not only those from SearXNG.

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 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 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

docker run

Use flags -it for interactive processes.

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

docker run --rm -it searxng/searxng -h

../dockerfiles/docker-entrypoint.sh -h