123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- <!DOCTYPE html>
- <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Step By Step How I Setup My HomeLab Docker Containers</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta charset="UTF-8">
- <meta name="keywords" content="How To Setup A Docker Environment,How To Setup A Docker Home Lab,How To Setup A Containerized Home Lab,Docker Made Simple,Docker Made Easy,Home Lab,Self-Hosted,Install Guide,Docker,Containers,Containerization,Home Server,VirtualBox,Pi-Hole,Apache,HTTPD,Guacamole,Heimdall,Portainer,MySQL,PostgreSQL,PhpMyAdmin,PhpPGAdmin,How To,Tutorial,i12bretro">
- <meta name="author" content="i12bretro">
- <meta name="description" content="Step By Step How I Setup My HomeLab Docker Containers">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="revised" content="03/14/2022 08:48:54 PM" />
- <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
- <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
- <script type="text/javascript" src="includes/js/steps.js"></script>
- <link href="css/steps.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="gridContainer">
- <div class="topMargin"></div>
- <div id="listName" class="topMargin">
- <h1>Step By Step How I Setup My HomeLab Docker Containers</h1>
- </div>
- <div></div>
- <div id="content">
- <h2>Installing VirtualBox</h2>
- <ol>
- <li>Download VirtualBox <a href="https://www.virtualbox.org/wiki/Downloads" target="_blank">Download</a></li>
- <li>Download VirtualBox Extension Pack <a href="https://www.virtualbox.org/wiki/Downloads" target="_blank">Download</a></li>
- <li>Install VirtualBox, accepting the defaults</li>
- <li>Install VirtualBox Extension Pack, accepting the defaults</li>
- <li>Launch VirtualBox if it is not already running</li>
- </ol>
- <h2>Creating TurnKey Core VirtualBox VM</h2>
- <ol>
- <li>Download the TurnKey Linux Core .ova <a href="https://www.turnkeylinux.org/core" target="_blank">Download</a></li>
- <li>In VirtualBox, select File > Import Appliance...</li>
- <li>Click the Browse icon > Navigate to and select the downloaded .ova file</li>
- <li>Click Next and then Import</li>
- <li>Make sure the Turnkey Core VM is selected and click Start > Normal</li>
- <li>Once the VM boots, enter a new root password</li>
- <li>Select Skip on the TurnKey Backup and Migration screen</li>
- <li>Select Skip on the System Notifications screen</li>
- <li>Select Install on the Security Updates screen</li>
- <li>Note the URLs and IP address for the VM > Press Enter to finish the installation</li>
- </ol>
- <h2>Installing Docker</h2>
- <ol>
- <li>Execute the following commands in a terminal:
- <div class="codeBlock"># update software repositories<br />
- apt update<br />
- # install necessary packages for https apt calls<br />
- apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common<br />
- # add docker GPG key<br />
- curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -<br />
- # add docker software repository<br />
- add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"<br />
- # install docker<br />
- apt update<br />
- apt install docker-ce docker-ce-cli containerd.io<br />
- # create a docker group<br />
- groupadd docker<br />
- # add the current user to the docker group<br />
- usermod -aG docker $USER</div>
- </li>
- </ol>
- <h2>Running Portainer Docker Container</h2>
- <ol>
- <li>Continue with the following commands in terminal to run Portainer:
- <div class="codeBlock"># create a working directory for portainer<br />
- mkdir ~/docker/portainer -p<br />
- # run the portainer docker container<br />
- docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v ~/docker/portainer:/data portainer/portainer-ce</div>
- </li>
- <li>Once the Portainer container is downloaded and running, open a web browser and navigate to http://DNSorIP:9000</li>
- <li>Set an administrator username and password > Click Create user</li>
- <li>Click the Docker - Manage the local Docker environment option > Click Connect</li>
- <li>Select Networks from the left navigation menu</li>
- <li>Click the Add Network button</li>
- <li>Complete the Create network form as follows:
- <p>Name: container-network<br />
- Subnet: 173.27.0.0/16<br />
- Gateway: 173.27.0.1</p>
- </li>
- <li>Click the Create the Network button at the bottom of the page</li>
- </ol>
- <h2>Adding Additional Docker Containers From Portainer UI</h2>
- <ol>
- <li>Select Containers from the left navigation menu</li>
- <li>For each of the containers listed below, click the Add Container button and complete the Create container form with the values given</li>
- </ol>
- <h3 style="margin-left: 80px;">Heimdall</h3>
- <p style="margin-left: 120px;">Name: heimdall<br />
- Image: ghcr.io/linuxserver/heimdall:latest<br />
- Ports: 40000 → 80<br />
- Volumes: /config → /root/docker/heimdall<br />
- Env:<br />
- PUID: 1000<br />
- PGID: 1000<br />
- TZ: America/New_York<br />
- Restart Policy: Unless Stopped</p>
- <h3 style="margin-left: 80px;">MySQL</h3>
- <p style="margin-left: 120px;">Name: MySQL<br />
- Image: mysql:latest<br />
- Ports: 3306 → 3306<br />
- Volumes: /var/lib/mysql → /root/docker/mysql<br />
- Env:<br />
- MYSQL_ROOT_PASSWORD: password<br />
- Restart Policy: Unless Stopped</p>
- <h3 style="margin-left: 80px;">phpMyAdmin</h3>
- <p style="margin-left: 120px;">Name: phpMyAdmin<br />
- Image: phpmyadmin:latest<br />
- Ports: 40001 → 80<br />
- Env:<br />
- PMA_HOST: MySQL<br />
- Restart Policy: Unless Stopped</p>
- <h3 style="margin-left: 80px;">PostgreSQL</h3>
- <p style="margin-left: 120px;">Name: postgres<br />
- Image: postgres:latest<br />
- Ports: 5432 → 5432<br />
- Volumes: /var/lib/postgresql/data → /root/docker/postgresql/data<br />
- Env:<br />
- POSTGRES_PASSWORD: postgres<br />
- Restart Policy: Unless Stopped</p>
- <h3 style="margin-left: 80px;">phpPGAdmin</h3>
- <p style="margin-left: 120px;">Name: phpPGAdmin<br />
- Image: bitnami/phppgadmin:latest<br />
- Ports: 40004 → 8080<br />
- Env:<br />
- POSTGRESQL_HOST: postgresql<br />
- Restart Policy: Unless Stopped</p>
- <h3 style="margin-left: 80px;">Watchtower</h3>
- <p style="margin-left: 120px;">Name: watchtower<br />
- Image: containrrr/watchtower:latest<br />
- Volumes: /var/run/docker.sock → /var/run/docker.sock<br />
- Env:<br />
- WATCHTOWER_NOTIFICATION_EMAIL_FROM: watchtower@i12bretro.local<br />
- WATCHTOWER_NOTIFICATION_EMAIL_TO: sysadmin@i12bretro.local<br />
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER: smtp.i12bretro.local<br />
- WATCHTOWER_NOTIFICATIONS: email<br />
- WATCHTOWER_NO_STARTUP_MESSAGE: true<br />
- Restart Policy: Unless Stopped</p>
- <h3 style="margin-left: 80px;">Apache HTTPD</h3>
- <p style="margin-left: 120px;">Name: httpd<br />
- Image: httpd:alpine<br />
- Ports: 80 → 80<br />
- Volumes: /usr/local/apache2/conf → /root/docker/apache2/conf<br />
- Restart Policy: Unless Stopped</p>
- <h3 style="margin-left: 80px;">Pi-Hole</h3>
- <p style="margin-left: 120px;">Name: pihole<br />
- Image: pihole/pihole:latest<br />
- Ports: 53 → 53, 53 → 53 UDP, 67 → 67 UDP, 40002 → 80<br />
- Volumes:<br />
- /etc/pihole/ → /root/docker/pihole/etc/<br />
- /etc/dnsmasq.d/ → /root/docker/pihole/dnsmasq.d/<br />
- Env:<br />
- TZ: America/New_York<br />
- WEBPASSWORD: password<br />
- Restart Policy: Unless Stopped</p>
- <h3 style="margin-left: 80px;">guacd</h3>
- <p style="margin-left: 120px;">Name: guacd<br />
- Image: guacamole/guacd:latest<br />
- Restart Policy: Unless Stopped</p>
- <h2>Completing Network Setup</h2>
- <ol>
- <li>Select Containers from the left navigation menu</li>
- <li>Click the MySQL container</li>
- <li>Scroll down to the Networks section > Select container-network from the dropdown > Click Join Network</li>
- <li>Do the same for the phpMyAdmin, Postgres, phpPGAdmin, guacd and Guacamole containers</li>
- </ol>
- <h2>Creating Apache HTTPD Reverse Proxy</h2>
- <ol>
- <li>Run the following command in terminal on the Docker host:
- <div class="codeBlock"># copy the httpd.conf from container to host<br />
- docker cp httpd:/usr/local/apache2/ /root/docker/apache2<br />
- # edit httpd.conf<br />
- nano ~/docker/apache2/conf/httpd.conf</div>
- </li>
- <li>Uncomment the following module lines by removing the #
- <p>LoadModule proxy_module modules/mod_proxy.so<br />
- LoadModule proxy_connect_module modules/mod_proxy_connect.so<br />
- LoadModule proxy_http_module modules/mod_proxy_http.so<br />
- LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so</p>
- </li>
- <li>Paste the following at the bottom of the file
- <p><label for="cb_li_866775_32">ProxyPreserveHost On</label></p>
- <p><label for="cb_li_866775_32"><Location /guacamole/><br />
- Order allow,deny<br />
- Allow from all<br />
- ProxyPass http://192.168.0.75:40003/guacamole/ flushpackets=on<br />
- ProxyPassReverse http://192.168.0.75:40003/guacamole/<br />
- </Location></label></p>
- <p><label for="cb_li_866775_32"><Location /guacamole/websocket-tunnel><br />
- Order allow,deny<br />
- Allow from all<br />
- ProxyPass ws://192.168.0.75:40003/guacamole/websocket-tunnel<br />
- ProxyPassReverse ws://192.168.0.75:40003/guacamole/websocket-tunnel<br />
- </Location></label></p>
- <p><label for="cb_li_866775_32"><Location /phpmyadmin/><br />
- Order allow,deny<br />
- Allow from all<br />
- ProxyPass http://192.168.0.75:40001/<br />
- ProxyPassReverse http://192.168.0.75:40001/<br />
- </Location></label></p>
- <p><label for="cb_li_866775_32"><Location /phppgadmin/><br />
- Order allow,deny<br />
- Allow from all<br />
- ProxyPass http://192.168.0.75:40004/<br />
- ProxyPassReverse http://192.168.0.75:40004/<br />
- </Location></label></p>
- <p><label for="cb_li_866775_32"><Location /pihole/><br />
- Order allow,deny<br />
- Allow from all<br />
- ProxyPass http://192.168.0.75:40002/admin/<br />
- ProxyPassReverse http://192.168.0.75:40002/admin/<br />
- </Location></label></p>
- <p><label for="cb_li_866775_32"><Location /portainer/><br />
- Order allow,deny<br />
- Allow from all<br />
- ProxyPass http://192.168.0.75:9000/<br />
- ProxyPassReverse http://192.168.0.75:9000/<br />
- </Location></label></p>
- <p><label for="cb_li_866775_32">ProxyPass / http://192.168.0.75:40000/<br />
- ProxyPassReverse / http://192.168.0.75:40000/</label></p>
- </li>
- <li>Press CTRL+O, Enter, CTRL+X to write the changes to httpd.conf</li>
- <li>Back in the Portainer UI, select Containers from the left navigation menu</li>
- <li>Check the box next to httpd > Click the Restart button</li>
- </ol>
- </div>
- </div>
- </body>
- </html>
-
|