JustToThePoint English Website Version
JustToThePoint en español
Colaborate with us

SearXNG: Your local private search engine.

Without pain, without sacrifice, we would have nothing, Chuck Palahniuk - Fight Club.

Topology and Limits

What is it?

SearXNG is a free and open-source metasearch engine forked from Searx which aggregates results from various search services and databases. Users are neither tracked nor profiled.

Why use it?

Installation using Docker

We are going to use Docker. Docker provides the ability to package and run an application in a loosely isolated environment called a container. The isolation and security allows you to run many containers simultaneously on a given host. Containers are lightweight and contain everything needed to run the application, so you do not need to rely on what is currently installed on the host.

#!/bin/bash

# Variables
CTID=309                  # Container ID
OSTEMPLATE="ubuntu-24.10-standard_24.10-1_amd64.tar.zst"
TEMPLATE_STORAGE="local"  # Storage for the template
CONTAINER_STORAGE="mypool" # Storage for the container's disk
DISK_SIZE="80"            # Disk size in GB
PASSWORD="YOUR-PASSWORD" # Root password
HOSTNAME="searx" # Hostname
MEMORY=4096              # Memory in MB (Docker needs more resources)
CORES=2                   # Number of CPU cores
BRIDGE="vmbr0"
IPADDRESS="192.168.1.59"      # Desired static IP
GATEWAY="192.168.1.1"         # Your LAN gateway
CIDR="/24"                    # Adjust if not 255.255.255.0
PORT=8080

# 1. If container $CTID exists, remove it (optional)
if pct status $CTID &>/dev/null; then
	echo "Container $CTID exists. Stopping the container."
	pct stop $CTID
	sleep 2 # Giving it a moment to stop gracefully
	echo "Proceeding with deletion of container $CTID."
	pct destroy $CTID
else echo "Container $CTID does not exist."
fi

# 2. Download template if needed
# Check if the template is already downloaded
if ! pveam list $TEMPLATE_STORAGE | grep -q $OSTEMPLATE; then
  echo "Downloading Ubuntu template..."
  pveam download $TEMPLATE_STORAGE $OSTEMPLATE
else
  echo "Ubuntu template already exists."
fi

# 3. Create a privileged Ubuntu container
# Create the container with 80 GB disk on mypool
pct create $CTID $TEMPLATE_STORAGE:vztmpl/$OSTEMPLATE \
  --storage $CONTAINER_STORAGE \
  --rootfs $CONTAINER_STORAGE:$DISK_SIZE \
  --password $PASSWORD \
  --hostname $HOSTNAME \
  --memory $MEMORY \
  --cores $CORES \
  --net0 name=eth0,bridge=$BRIDGE,ip=$IPADDRESS$CIDR,gw=$GATEWAY \
  --unprivileged 0         # Set to 1 for unprivileged containers

pct set $CTID --onboot 0

# 4. Configure network interface with DHCP
# pct set $CTID --net0 name=eth0,bridge=vmbr0,ip=dhcp,firewall=0
# pct set $CTID --nameserver 8.8.8.8
# Setup a static IP via Cloud-Init (if you want):
# qm set $CTID --ipconfig0 ip=$IPADDRESS$CIDR,gw=$GATEWAY

# 5. Enable the "keyctl" feature (required for Docker) and Docker nesting features (if needed)
pct set $CTID --features nesting=1,keyctl=1,mknod=1

# (Optional) Unconfine AppArmor
echo "lxc.apparmor.profile: unconfined" >> /etc/pve/lxc/$CTID.conf

# 6. Start container
pct start $CTID

# Wait a moment for container to boot
sleep 5

# 7. Install Docker inside the Ubuntu container
pct exec $CTID -- apt-get update
pct exec $CTID -- apt-get install -y docker.io

pct exec $CTID -- echo "root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
pct exec $CTID -- echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers


# Enable and start Docker
pct exec $CTID -- systemctl enable docker
pct exec $CTID -- systemctl start docker

# Test Docker
echo "Test Docker"
pct exec $CTID -- docker run hello-world

# Check IP addresses
echo "Check IP addresses"
pct exec $CTID -- ip a

# Test Docker
echo "Test Docker"
pct exec $CTID -- docker run hello-world

# If you see an IP, test connectivity
pct exec $CTID -- ping -c 3 google.com

pct exec $CTID -- mkdir -p /etc/local.d
mkdir my-instance

echo "Creating the startup-script.service"
pct exec $CTID -- bash -c "cat > /etc/systemd/system/startup-script.service << 'EOF'
[Unit]
Description=Startup Script to run Kasm Docker container
After=network.target docker.service

[Service]
Type=simple
ExecStart=/etc/local.d/searx-startup.sh
RemainAfterExit=true

[Install]
WantedBy=multi-user.target
EOF"

pct exec $CTID -- bash -c "cat > /etc/local.d/searx-startup.sh << 'EOF'
#!/bin/bash
# Ensure Docker is running
while ! systemctl is-active --quiet docker; do
    echo 'Waiting for Docker...'
    sleep 1
done

# If container is already running, stop/remove it (optional)
docker rm -f searx_container 2>/dev/null || true

cd my-instance
docker pull searxng/searxng

# Run container in detached mode
docker run -d --name searx_container \
  -p ${PORT}:8080 \
  -v "${PWD}/searxng:/etc/searxng" \
  -e "BASE_URL=http://localhost:$PORT/" \
  -e "INSTANCE_NAME=my-instance" \
  searxng/searxng

EOF"

pct exec $CTID -- chmod +x /etc/local.d/searx-startup.sh

pct exec $CTID -- systemctl daemon-reload
pct exec $CTID -- systemctl enable startup-script.service
pct exec $CTID -- systemctl start startup-script.service
# Output success message
echo "Ubuntu-based LXC container $CTID created with Docker installed. https://192.168.1.59:8080/"
echo "Searx is running on port 8080.
pct exec $CTID -- ip a

Use

Open your favorite browser and go to [HTTP:] + [//dirIP_Container_Hosting_Searx] : [8080/] and enjoy!

Bitcoin donation

JustToThePoint Copyright © 2011 - 2025 Anawim. ALL RIGHTS RESERVED. Bilingual e-books, articles, and videos to help your child and your entire family succeed, develop a healthy lifestyle, and have a lot of fun. Social Issues, Join us.

This website uses cookies to improve your navigation experience.
By continuing, you are consenting to our use of cookies, in accordance with our Cookies Policy and Website Terms and Conditions of use.