installation-docker.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="../">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <title>Docker Container &#8212; SearXNG Documentation (2025.5.20+7a3742ae5)</title>
  8. <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
  9. <link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
  10. <script src="../_static/documentation_options.js?v=bb66e092"></script>
  11. <script src="../_static/doctools.js?v=9a2dae69"></script>
  12. <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
  13. <script data-project="searxng" data-version="2025.5.20+7a3742ae5" src="../_static/describe_version.js?v=fa7f30d0"></script>
  14. <link rel="index" title="Index" href="../genindex.html" />
  15. <link rel="search" title="Search" href="../search.html" />
  16. <link rel="next" title="Installation Script" href="installation-scripts.html" />
  17. <link rel="prev" title="Installation" href="installation.html" />
  18. </head><body>
  19. <div class="related" role="navigation" aria-label="Related">
  20. <h3>Navigation</h3>
  21. <ul>
  22. <li class="right" style="margin-right: 10px">
  23. <a href="../genindex.html" title="General Index"
  24. accesskey="I">index</a></li>
  25. <li class="right" >
  26. <a href="../py-modindex.html" title="Python Module Index"
  27. >modules</a> |</li>
  28. <li class="right" >
  29. <a href="installation-scripts.html" title="Installation Script"
  30. accesskey="N">next</a> |</li>
  31. <li class="right" >
  32. <a href="installation.html" title="Installation"
  33. accesskey="P">previous</a> |</li>
  34. <li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.5.20+7a3742ae5)</a> &#187;</li>
  35. <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Administrator documentation</a> &#187;</li>
  36. <li class="nav-item nav-item-this"><a href="">Docker Container</a></li>
  37. </ul>
  38. </div>
  39. <div class="document">
  40. <div class="documentwrapper">
  41. <div class="bodywrapper">
  42. <div class="body" role="main">
  43. <section id="docker-container">
  44. <span id="installation-docker"></span><h1>Docker Container<a class="headerlink" href="#docker-container" title="Link to this heading">¶</a></h1>
  45. <hr class="docutils" />
  46. <aside class="sidebar">
  47. <p class="sidebar-title">info</p>
  48. <ul class="simple">
  49. <li><p><a class="reference external" href="https://hub.docker.com/r/searxng/searxng">searxng/searxng &#64;dockerhub</a></p></li>
  50. <li><p><a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/Dockerfile">git://Dockerfile</a></p></li>
  51. <li><p><a class="reference external" href="https://docs.docker.com/get-started/overview">Docker overview</a></p></li>
  52. <li><p><a class="reference external" href="https://docs.docker.com/get-started/docker_cheatsheet.pdf">Docker Cheat Sheet</a></p></li>
  53. <li><p><a class="reference external" href="https://alpinelinux.org">Alpine Linux</a>
  54. <a class="reference external" href="https://en.wikipedia.org/wiki/Alpine_Linux">(wiki)</a>
  55. <a class="reference external" href="https://pkgs.alpinelinux.org/packages">apt packages</a></p></li>
  56. <li><p>Alpine’s <code class="docutils literal notranslate"><span class="pre">/bin/sh</span></code> is <a class="extlink-man reference external" href="https://manpages.debian.org/jump?q=dash">dash</a></p></li>
  57. </ul>
  58. </aside>
  59. <p><strong>If you intend to create a public instance using Docker, use our well maintained
  60. docker container</strong></p>
  61. <ul class="simple">
  62. <li><p><a class="reference external" href="https://hub.docker.com/r/searxng/searxng">searxng/searxng &#64;dockerhub</a>.</p></li>
  63. </ul>
  64. <aside class="sidebar">
  65. <p class="sidebar-title">hint</p>
  66. <p>The rest of this article is of interest only to those who want to create and
  67. maintain their own Docker images.</p>
  68. </aside>
  69. <p>The sources are hosted at <a class="reference external" href="https://github.com/searxng/searxng-docker">searxng-docker</a> and the container includes:</p>
  70. <ul class="simple">
  71. <li><p>a HTTPS reverse proxy <a class="reference external" href="https://hub.docker.com/_/caddy">[caddy]</a> and</p></li>
  72. <li><p>a <a class="reference external" href="https://redis.io/">Redis</a> DB</p></li>
  73. </ul>
  74. <p>The <a class="reference external" href="https://github.com/searxng/searxng-docker/blob/master/searxng/settings.yml">default SearXNG setup</a>
  75. of this container:</p>
  76. <ul class="simple">
  77. <li><p>enables <a class="reference internal" href="searx.limiter.html#limiter"><span class="std std-ref">limiter</span></a> to protect against bots</p></li>
  78. <li><p>enables <a class="reference internal" href="settings/settings_server.html#image-proxy"><span class="std std-ref">image proxy</span></a> for better privacy</p></li>
  79. <li><p>enables <a class="reference internal" href="settings/settings_ui.html#static-use-hash"><span class="std std-ref">cache busting</span></a> to save bandwidth</p></li>
  80. </ul>
  81. <hr class="docutils" />
  82. <section id="get-docker">
  83. <h2>Get Docker<a class="headerlink" href="#get-docker" title="Link to this heading">¶</a></h2>
  84. <p>If you plan to build and maintain a docker image by yourself, make sure you have
  85. <a class="reference external" href="https://docs.docker.com/get-docker/">Docker installed</a>. On Linux don’t
  86. forget to add your user to the docker group (log out and log back in so that
  87. your group membership is re-evaluated):</p>
  88. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$<span class="w"> </span>sudo<span class="w"> </span>usermod<span class="w"> </span>-a<span class="w"> </span>-G<span class="w"> </span>docker<span class="w"> </span><span class="nv">$USER</span>
  89. </pre></div>
  90. </div>
  91. </section>
  92. <section id="searxng-searxng">
  93. <h2>searxng/searxng<a class="headerlink" href="#searxng-searxng" title="Link to this heading">¶</a></h2>
  94. <aside class="sidebar">
  95. <p class="sidebar-title"><code class="docutils literal notranslate"><span class="pre">docker</span> <span class="pre">run</span></code></p>
  96. <ul class="simple">
  97. <li><p><a class="reference external" href="https://docs.docker.com/engine/reference/run/#clean-up---rm">--rm</a>
  98. automatically clean up when container exits</p></li>
  99. <li><p><a class="reference external" href="https://docs.docker.com/engine/reference/run/#detached--d">-d</a> start
  100. detached container</p></li>
  101. <li><p><a class="reference external" href="https://docs.docker.com/engine/reference/run/#volume-shared-filesystems">-v</a>
  102. mount volume <code class="docutils literal notranslate"><span class="pre">HOST:CONTAINER</span></code></p></li>
  103. </ul>
  104. </aside>
  105. <p>The docker image is based on <a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/Dockerfile">git://Dockerfile</a> and available from
  106. <a class="reference external" href="https://hub.docker.com/r/searxng/searxng">searxng/searxng &#64;dockerhub</a>. Using the docker image is quite easy, for
  107. instance you can pull the <a class="reference external" href="https://hub.docker.com/r/searxng/searxng">searxng/searxng &#64;dockerhub</a> image and deploy a local
  108. instance using <a class="reference external" href="https://docs.docker.com/engine/reference/run/">docker run</a>:</p>
  109. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$<span class="w"> </span>mkdir<span class="w"> </span>my-instance
  110. $<span class="w"> </span><span class="nb">cd</span><span class="w"> </span>my-instance
  111. $<span class="w"> </span><span class="nb">export</span><span class="w"> </span><span class="nv">PORT</span><span class="o">=</span><span class="m">8080</span>
  112. $<span class="w"> </span>docker<span class="w"> </span>pull<span class="w"> </span>searxng/searxng
  113. $<span class="w"> </span>docker<span class="w"> </span>run<span class="w"> </span>--rm<span class="w"> </span><span class="se">\</span>
  114. <span class="w"> </span>-d<span class="w"> </span>-p<span class="w"> </span><span class="si">${</span><span class="nv">PORT</span><span class="si">}</span>:8080<span class="w"> </span><span class="se">\</span>
  115. <span class="w"> </span>-v<span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PWD</span><span class="si">}</span><span class="s2">/searxng:/etc/searxng&quot;</span><span class="w"> </span><span class="se">\</span>
  116. <span class="w"> </span>-e<span class="w"> </span><span class="s2">&quot;BASE_URL=http://localhost:</span><span class="nv">$PORT</span><span class="s2">/&quot;</span><span class="w"> </span><span class="se">\</span>
  117. <span class="w"> </span>-e<span class="w"> </span><span class="s2">&quot;INSTANCE_NAME=my-instance&quot;</span><span class="w"> </span><span class="se">\</span>
  118. <span class="w"> </span>searxng/searxng
  119. 2f998....<span class="w"> </span><span class="c1"># container&#39;s ID</span>
  120. </pre></div>
  121. </div>
  122. <p>The environment variables UWSGI_WORKERS and UWSGI_THREADS overwrite the default
  123. number of UWSGI processes and UWSGI threads specified in <cite>/etc/searxng/uwsgi.ini</cite>.</p>
  124. <p>Open your WEB browser and visit the URL:</p>
  125. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$<span class="w"> </span>xdg-open<span class="w"> </span><span class="s2">&quot;http://localhost:</span><span class="nv">$PORT</span><span class="s2">&quot;</span>
  126. </pre></div>
  127. </div>
  128. <p>Inside <code class="docutils literal notranslate"><span class="pre">${PWD}/searxng</span></code>, you will find <code class="docutils literal notranslate"><span class="pre">settings.yml</span></code> and <code class="docutils literal notranslate"><span class="pre">uwsgi.ini</span></code>. You
  129. can modify these files according to your needs and restart the Docker image.</p>
  130. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$<span class="w"> </span>docker<span class="w"> </span>container<span class="w"> </span>restart<span class="w"> </span>2f998
  131. </pre></div>
  132. </div>
  133. <p>Use command <code class="docutils literal notranslate"><span class="pre">container</span> <span class="pre">ls</span></code> to list running containers, add flag <a class="reference external" href="https://docs.docker.com/engine/reference/commandline/container_ls">-a</a> to list
  134. exited containers also. With <code class="docutils literal notranslate"><span class="pre">container</span> <span class="pre">stop</span></code> a running container can be
  135. stopped. To get rid of a container use <code class="docutils literal notranslate"><span class="pre">container</span> <span class="pre">rm</span></code>:</p>
  136. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$<span class="w"> </span>docker<span class="w"> </span>container<span class="w"> </span>ls
  137. CONTAINER<span class="w"> </span>ID<span class="w"> </span>IMAGE<span class="w"> </span>COMMAND<span class="w"> </span>CREATED<span class="w"> </span>...
  138. 2f998d725993<span class="w"> </span>searxng/searxng<span class="w"> </span><span class="s2">&quot;/sbin/tini -- /usr/…&quot;</span><span class="w"> </span><span class="m">7</span><span class="w"> </span>minutes<span class="w"> </span>ago<span class="w"> </span>...
  139. $<span class="w"> </span>docker<span class="w"> </span>container<span class="w"> </span>stop<span class="w"> </span>2f998
  140. $<span class="w"> </span>docker<span class="w"> </span>container<span class="w"> </span>rm<span class="w"> </span>2f998
  141. </pre></div>
  142. </div>
  143. <aside class="sidebar">
  144. <p class="sidebar-title">Warning</p>
  145. <p>This might remove all docker items, not only those from SearXNG.</p>
  146. </aside>
  147. <p>If you won’t use docker anymore and want to get rid of all containers &amp; images
  148. use the following <em>prune</em> command:</p>
  149. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$<span class="w"> </span>docker<span class="w"> </span>stop<span class="w"> </span><span class="k">$(</span>docker<span class="w"> </span>ps<span class="w"> </span>-aq<span class="k">)</span><span class="w"> </span><span class="c1"># stop all containers</span>
  150. $<span class="w"> </span>docker<span class="w"> </span>system<span class="w"> </span>prune<span class="w"> </span><span class="c1"># make some housekeeping</span>
  151. $<span class="w"> </span>docker<span class="w"> </span>rmi<span class="w"> </span>-f<span class="w"> </span><span class="k">$(</span>docker<span class="w"> </span>images<span class="w"> </span>-q<span class="k">)</span><span class="w"> </span><span class="c1"># drop all images</span>
  152. </pre></div>
  153. </div>
  154. <section id="shell-inside-container">
  155. <h3>shell inside container<a class="headerlink" href="#shell-inside-container" title="Link to this heading">¶</a></h3>
  156. <aside class="sidebar">
  157. <p class="sidebar-title">Bashism</p>
  158. <ul class="simple">
  159. <li><p><a class="reference external" href="https://lwn.net/Articles/343924/">A tale of two shells: bash or dash</a></p></li>
  160. <li><p><a class="reference external" href="http://mywiki.wooledge.org/Bashism">How to make bash scripts work in dash</a></p></li>
  161. <li><p><a class="reference external" href="https://dev.to/bowmanjd/writing-bash-scripts-that-are-not-only-bash-checking-for-bashisms-and-testing-with-dash-1bli">Checking for Bashisms</a></p></li>
  162. </ul>
  163. </aside>
  164. <p>To open a shell inside the container:</p>
  165. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$<span class="w"> </span>docker<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>-it<span class="w"> </span>2f998<span class="w"> </span>sh
  166. </pre></div>
  167. </div>
  168. </section>
  169. </section>
  170. <section id="build-the-image">
  171. <h2>Build the image<a class="headerlink" href="#build-the-image" title="Link to this heading">¶</a></h2>
  172. <p>It’s also possible to build SearXNG from the embedded <a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/Dockerfile">git://Dockerfile</a>:</p>
  173. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ git clone https://github.com/searxng/searxng.git
  174. $ cd searxng
  175. $ make docker.build
  176. ...
  177. Successfully built 49586c016434
  178. Successfully tagged searxng/searxng:latest
  179. Successfully tagged searxng/searxng:1.0.0-209-9c823800-dirty
  180. $ docker images
  181. REPOSITORY TAG IMAGE ID CREATED SIZE
  182. searxng/searxng 1.0.0-209-9c823800-dirty 49586c016434 13 minutes ago 308MB
  183. searxng/searxng latest 49586c016434 13 minutes ago 308MB
  184. alpine 3.13 6dbb9cc54074 3 weeks ago 5.61MB
  185. </pre></div>
  186. </div>
  187. </section>
  188. <section id="command-line">
  189. <h2>Command line<a class="headerlink" href="#command-line" title="Link to this heading">¶</a></h2>
  190. <aside class="sidebar">
  191. <p class="sidebar-title">docker run</p>
  192. <p>Use flags <code class="docutils literal notranslate"><span class="pre">-it</span></code> for <a class="reference external" href="https://docs.docker.com/engine/reference/run/#foreground">interactive processes</a>.</p>
  193. </aside>
  194. <p>In the <a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/Dockerfile">git://Dockerfile</a> the <a class="reference external" href="https://docs.docker.com/engine/reference/builder/#entrypoint">ENTRYPOINT</a> is defined as
  195. <a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/container/entrypoint.sh">git://container/entrypoint.sh</a></p>
  196. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>docker<span class="w"> </span>run<span class="w"> </span>--rm<span class="w"> </span>-it<span class="w"> </span>searxng/searxng<span class="w"> </span>-h
  197. </pre></div>
  198. </div>
  199. <div class="highlight-text notranslate"><div class="highlight"><pre><span></span>../container/entrypoint.sh: 152: SEARXNG_VERSION: parameter not set
  200. </pre></div>
  201. </div>
  202. </section>
  203. </section>
  204. <div class="clearer"></div>
  205. </div>
  206. </div>
  207. </div>
  208. <span id="sidebar-top"></span>
  209. <div class="sphinxsidebar" role="navigation" aria-label="Main">
  210. <div class="sphinxsidebarwrapper">
  211. <p class="logo"><a href="../index.html">
  212. <img class="logo" src="../_static/searxng-wordmark.svg" alt="Logo of SearXNG"/>
  213. </a></p>
  214. <h3><a href="../index.html">Table of Contents</a></h3>
  215. <ul class="current">
  216. <li class="toctree-l1"><a class="reference internal" href="../user/index.html">User information</a></li>
  217. <li class="toctree-l1"><a class="reference internal" href="../own-instance.html">Why use a private instance?</a></li>
  218. <li class="toctree-l1 current"><a class="reference internal" href="index.html">Administrator documentation</a><ul class="current">
  219. <li class="toctree-l2"><a class="reference internal" href="settings/index.html">Settings</a></li>
  220. <li class="toctree-l2"><a class="reference internal" href="installation.html">Installation</a></li>
  221. <li class="toctree-l2 current"><a class="current reference internal" href="#">Docker Container</a><ul>
  222. <li class="toctree-l3"><a class="reference internal" href="#get-docker">Get Docker</a></li>
  223. <li class="toctree-l3"><a class="reference internal" href="#searxng-searxng">searxng/searxng</a><ul>
  224. <li class="toctree-l4"><a class="reference internal" href="#shell-inside-container">shell inside container</a></li>
  225. </ul>
  226. </li>
  227. <li class="toctree-l3"><a class="reference internal" href="#build-the-image">Build the image</a></li>
  228. <li class="toctree-l3"><a class="reference internal" href="#command-line">Command line</a></li>
  229. </ul>
  230. </li>
  231. <li class="toctree-l2"><a class="reference internal" href="installation-scripts.html">Installation Script</a></li>
  232. <li class="toctree-l2"><a class="reference internal" href="installation-searxng.html">Step by step installation</a></li>
  233. <li class="toctree-l2"><a class="reference internal" href="installation-uwsgi.html">uWSGI</a></li>
  234. <li class="toctree-l2"><a class="reference internal" href="installation-nginx.html">NGINX</a></li>
  235. <li class="toctree-l2"><a class="reference internal" href="installation-apache.html">Apache</a></li>
  236. <li class="toctree-l2"><a class="reference internal" href="update-searxng.html">SearXNG maintenance</a></li>
  237. <li class="toctree-l2"><a class="reference internal" href="answer-captcha.html">Answer CAPTCHA from server’s IP</a></li>
  238. <li class="toctree-l2"><a class="reference internal" href="searx.favicons.html">Favicons</a></li>
  239. <li class="toctree-l2"><a class="reference internal" href="searx.limiter.html">Limiter</a></li>
  240. <li class="toctree-l2"><a class="reference internal" href="api.html">Administration API</a></li>
  241. <li class="toctree-l2"><a class="reference internal" href="architecture.html">Architecture</a></li>
  242. <li class="toctree-l2"><a class="reference internal" href="plugins.html">List of plugins</a></li>
  243. <li class="toctree-l2"><a class="reference internal" href="buildhosts.html">Buildhosts</a></li>
  244. </ul>
  245. </li>
  246. <li class="toctree-l1"><a class="reference internal" href="../dev/index.html">Developer documentation</a></li>
  247. <li class="toctree-l1"><a class="reference internal" href="../utils/index.html">DevOps tooling box</a></li>
  248. <li class="toctree-l1"><a class="reference internal" href="../src/index.html">Source-Code</a></li>
  249. </ul>
  250. <h3>Project Links</h3>
  251. <ul>
  252. <li><a href="https://github.com/searxng/searxng/tree/master">Source</a>
  253. <li><a href="https://github.com/searxng/searxng/wiki">Wiki</a>
  254. <li><a href="https://searx.space">Public instances</a>
  255. <li><a href="https://github.com/searxng/searxng/issues">Issue Tracker</a>
  256. </ul><h3>Navigation</h3>
  257. <ul>
  258. <li><a href="../index.html">Overview</a>
  259. <ul>
  260. <li><a href="index.html">Administrator documentation</a>
  261. <ul>
  262. <li>Previous: <a href="installation.html" title="previous chapter">Installation</a>
  263. <li>Next: <a href="installation-scripts.html" title="next chapter">Installation Script</a></ul>
  264. </li>
  265. </ul>
  266. </li>
  267. </ul>
  268. <search id="searchbox" style="display: none" role="search">
  269. <h3 id="searchlabel">Quick search</h3>
  270. <div class="searchformwrapper">
  271. <form class="search" action="../search.html" method="get">
  272. <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
  273. <input type="submit" value="Go" />
  274. </form>
  275. </div>
  276. </search>
  277. <script>document.getElementById('searchbox').style.display = "block"</script>
  278. <div role="note" aria-label="source link">
  279. <h3>This Page</h3>
  280. <ul class="this-page-menu">
  281. <li><a href="../_sources/admin/installation-docker.rst.txt"
  282. rel="nofollow">Show Source</a></li>
  283. </ul>
  284. </div>
  285. </div>
  286. </div>
  287. <div class="clearer"></div>
  288. </div>
  289. <div class="footer" role="contentinfo">
  290. &#169; Copyright SearXNG team.
  291. </div>
  292. </body>
  293. </html>