{"id":60,"date":"2022-04-06T13:59:45","date_gmt":"2022-04-06T12:59:45","guid":{"rendered":"https:\/\/steambot.ch\/blog\/?p=60"},"modified":"2022-04-09T14:18:43","modified_gmt":"2022-04-09T13:18:43","slug":"install-pi-hole-using-docker","status":"publish","type":"post","link":"https:\/\/steambot.ch\/blog\/?p=60","title":{"rendered":"Deploying applications on docker"},"content":{"rendered":"\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/Docker_(software)\" target=\"_blank\">Docker<\/a> is a very useful tool to easily deploy applications without having to worry about your server configuration, libraries, etc. Many softwares nowadays are packaged in the form of a docker image and lots are supported by the arm architecture of raspberry pis.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Linuxserver.io<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.linuxserver.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">Linuxserver.io<\/a> provided a large and very well maintained catalogue of docker images and configurations you can very easily deploy on many architectures. Have a look at their <a href=\"https:\/\/fleet.linuxserver.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">website<\/a> and pick and choose the applications that better suit your needs.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/steambot.ch\/blog\/wp-content\/uploads\/2022\/04\/LinuxServer-Logo-CMYK-1024x316.png\" alt=\"\" class=\"wp-image-129\" width=\"418\" height=\"129\" srcset=\"https:\/\/steambot.ch\/blog\/wp-content\/uploads\/2022\/04\/LinuxServer-Logo-CMYK-1024x316.png 1024w, https:\/\/steambot.ch\/blog\/wp-content\/uploads\/2022\/04\/LinuxServer-Logo-CMYK-300x93.png 300w, https:\/\/steambot.ch\/blog\/wp-content\/uploads\/2022\/04\/LinuxServer-Logo-CMYK-768x237.png 768w, https:\/\/steambot.ch\/blog\/wp-content\/uploads\/2022\/04\/LinuxServer-Logo-CMYK.png 1200w\" sizes=\"auto, (max-width: 418px) 100vw, 418px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Reverse proxy<\/h2>\n\n\n\n<p>Managing many applications, opening ports and configuring networks might get complex pretty fast. That&#8217;s why you might want to use a reverse proxy to have an easy web access to all of your docker services. In addition to simplified access through customizable URLs, reverse proxies allow you to encrypt all of your web communications by redirecting your docker services through https. Have a look for instance at <a rel=\"noreferrer noopener\" href=\"https:\/\/doc.traefik.io\/traefik\/\" target=\"_blank\">treafik reverse proxy<\/a> and follow their instructions for installation and deployment.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/doc.traefik.io\/traefik\/assets\/img\/traefik-architecture.png\" alt=\"\" width=\"639\" height=\"333\"\/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Pi-Hole<\/h2>\n\n\n\n<p>Deploying Pi-Hole on docker may not be as simple as running the container provided on <a rel=\"noreferrer noopener\" href=\"https:\/\/hub.docker.com\/\" target=\"_blank\">dockerhub<\/a>. Here is a working install that will allow you to easily deploy pihole in a few steps.<\/p>\n\n\n\n<p>Note that I assume here that you have a working docker and <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.docker.com\/compose\/\" target=\"_blank\">docker-compose<\/a> install and that you already run a <a rel=\"noreferrer noopener\" href=\"https:\/\/traefik.io\/traefik\/\" target=\"_blank\">traefik reverse proxy<\/a>. You will easily find details online on how to install and set this up.<\/p>\n\n\n\n<p>Now let&#8217;s go back at our pihole installation: First, create a <code>Dockerfile<\/code> for your dhcp-helper service as follows<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim Dockerfile<\/code><\/pre>\n\n\n\n<p>and insert the following instructions inside<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM alpine:3.12\nRUN apk --no-cache add dhcp-helper\nEXPOSE 67 67\/udp\nENTRYPOINT &#91;\"dhcp-helper\", \"-n\"]<\/code><\/pre>\n\n\n\n<p>Now you just need to create the docker-compose yaml file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim docker-compose.yml<\/code><\/pre>\n\n\n\n<p>with the following configuration<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>version: \"3\"\n\n\nservices:\n  pihole:\n    container_name: pihole\n    image: pihole\/pihole:latest\n    ports:\n      - \"53:53\/tcp\"\n      - \"53:53\/udp\"\n    environment:\n      TZ: 'Europe\/London'\n      WEBPASSWORD: '&lt;My_PASSWORD&gt;' # set a secure password here or it will be random\n      DNSMASQ_LISTENING: 'all'\n      ServerIP: '192.168.1.XX'\n      DNS1: '9.9.9.9' # Or your favorite DNS server 1\n      DNS2: '149.112.112.112'\n # Or your favorite DNS server 2\n      VIRTUAL_HOST: '&lt;Machine_hostname&gt;'\n    # Volumes store your data between container upgrades\n    volumes:\n       - '.\/etc-pihole\/:\/etc\/pihole\/'\n       - '.\/etc-dnsmasq.d\/:\/etc\/dnsmasq.d\/'\n    dns:\n      - 127.0.0.1\n      - 1.1.1.1\n    # Recommended but not required (DHCP needs NET_ADMIN)\n    #   see https:\/\/github.com\/pi-hole\/docker-pi-hole#note-on-capabilities\n    cap_add:\n      - NET_ADMIN\n    restart: unless-stopped\n    depends_on:\n      - dhcphelper\n    labels:\n      - \"traefik.enable=true\"\n      - \"traefik.http.routers.pihole.rule=Host(`pihole.mydomain.com`)\"\n      - \"traefik.docker.network=proxy\"\n      - \"traefik.http.services.pihole.loadbalancer.server.port=80\"\n      - \"traefik.http.routers.pihole.tls=true\"\n      - \"traefik.http.routers.pihole.entrypoints=websecure\"\n    networks:\n      proxy:\n        ipv4_address: '172.18.0.45'\n      backend:\n        ipv4_address: '172.31.0.100'\n\n  dhcphelper:\n    build: .\/\n    restart: unless-stopped\n    network_mode: \"host\"\n    command: -s 172.31.0.100\n    cap_add:\n      - NET_ADMIN\n\nnetworks:\n  backend:\n    ipam:\n      config:\n        - subnet: 172.31.0.0\/16\n    driver_opts:\n      com.docker.network.bridge.name: br_pihole\n  proxy:\n    external: true\n<\/code><\/pre>\n\n\n\n<p>And just start the container with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker-compose up -d<\/code><\/pre>\n\n\n\n<p>that&#8217;s it, pihole is running on your machine.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Other docker images worth considering<\/h2>\n\n\n\n<p>Below are some other great applications, unfortunately not provided by Linexserver.io as of today, but that you might want to check out:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">Glances <\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">(<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">t<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">o<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">g<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">e<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">t<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">h<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">e<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">r<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\"> <\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">w<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">i<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">t<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\">h<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/nicolargo.github.io\/glances\/\" target=\"_blank\"> Grafana)<\/a> &#8211; to monitor your machine and your docker containers<\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/miniflux.app\/\" target=\"_blank\">Miniflux<\/a> &#8211; to centralize and read your RSS feeds<\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/shaarli.readthedocs.io\/en\/master\/\" target=\"_blank\">Shaarli<\/a> &#8211; to manage your bookmarks<\/li><li>&#8230; Any other ideas or recommandations? feel free to share in the comments section.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Docker is a very useful tool to easily deploy applications without having to worry about your server configuration, libraries, etc. Many softwares nowadays are packaged in the form of a docker image and lots are supported by the arm architecture of raspberry pis. Linuxserver.io Linuxserver.io provided a large and very well maintained catalogue of docker [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[12,15,11,13,14],"class_list":["post-60","post","type-post","status-publish","format-standard","hentry","category-docker","tag-docker","tag-linuxserver","tag-pihole","tag-proxy","tag-traefik"],"_links":{"self":[{"href":"https:\/\/steambot.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/60","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/steambot.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/steambot.ch\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/steambot.ch\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/steambot.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=60"}],"version-history":[{"count":26,"href":"https:\/\/steambot.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":131,"href":"https:\/\/steambot.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/60\/revisions\/131"}],"wp:attachment":[{"href":"https:\/\/steambot.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/steambot.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/steambot.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}