searxng/docs/admin/installation-docker.rst
Markus Heiser ed8a169029 [doc] update documentation of the installation procedures
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-07-30 13:39:35 +02:00

6.1 KiB

Docker Container


If you intend to create a public instance using Docker, use our well maintained docker container

hint

The rest of this article is of interest only to those who want to create and maintain their own Docker images.

The sources are hosted at searxng-docker and the container includes:

The default SearXNG setup of this container:

  • enables limiter <limiter> to protect against bots
  • enables image proxy <image_proxy> for better privacy
  • enables cache busting <static_use_hash> to save bandwith

Get Docker

If you plan to build and maintain a docker image by your own, make sure you have Docker installed 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}/searxng:/etc/searxng" \
             -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}/searxng, 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 searxng
$ 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