Wiki source code of Docker containers
Last modified by Jan Rhebergen on 2022/01/24 15:56
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | (% class="box" id="HTableofcontent" %) | ||
| 2 | ((( | ||
| 3 | (% class="lead" id="HTableofcontent" %) | ||
| 4 | Table of content: | ||
| 5 | |||
| 6 | {{toc/}} | ||
| 7 | ))) | ||
| 8 | |||
| 9 | |||
| 10 | = background = | ||
| 11 | |||
| 12 | |||
| 13 | The basis of the Linux cluster is formed by two hosts that employ a number of docker containers to realise the desired functionality. These two hosts are called ##liszt## and ##beethoven##. | ||
| 14 | |||
| 15 | There are also two domains that we use to easy external access. These are ##informeer.de## and ##bladzij.de## Generally we use ##informeer.de## for services hosted on ##liszt## and ##bladzij.de## for services hosted on ##beethoven## (although not exclusively). | ||
| 16 | |||
| 17 | Currently the setup is realised in such a way that ##liszt## manages overall (web) access by means of the https://proxyman.informeer.de This service is supplied by the ##nginxproxymanager docker container##. | ||
| 18 | |||
| 19 | In this section we will discuss which containers are present and how they are created and maintained. A simplified overview can be found [[here>>doc:UOG.Technical Documentation.Remote access.WebHome]]. Please note that contrary to the diagram/sketc the port numbers 80 and 443 had to be maintained because only those ports can be used to request SSL certificated from //"Letsencrypt"//. This means the ssh tunnel does //**not**// use ports 4443 and 8080 but the original port 443 and 80. | ||
| 20 | |||
| 21 | Both ##beethoven## and ##liszt## have at least these two docker images running: | ||
| 22 | |||
| 23 | * nginxproxymanager https://nginxproxymanager.com/ | ||
| 24 | * portainer https://www.portainer.io/ | ||
| 25 | |||
| 26 | ##portainer## is a nice browser/webbased gui that make docker container management (and deployment) easy. Currently we mostly do the container installation by hand and use the webgui as a dashboard for starting/stopping and tweaking. | ||
| 27 | |||
| 28 | = nginxproxymanager = | ||
| 29 | |||
| 30 | This container is present on both ##liszt## and ##beethoven##. However the one os ##liszt## is the important/critical one. The one on ##beethoven## is there for historical reasons. This is because ##beethoven## was temporarily not allowed to be connected to the internet and its tasks had to be taken over bij ##liszt##. Ideally the setup should be such that we can remove ##liszt## from the network withour consequence. Currently that is definitely //**not**// the case (so don't do it). If absolutely needed it can be arranged but for now it is considered too much work to be worthwhile. | ||
| 31 | |||
| 32 | == installation == | ||
| 33 | |||
| 34 | Below the ##docker-compose.yaml## file that is used to create the ##nginxproxymanager## container. | ||
| 35 | |||
| 36 | (% class="box" %) | ||
| 37 | {{{version: "3" | ||
| 38 | services: | ||
| 39 | app: | ||
| 40 | image: 'jc21/nginx-proxy-manager:latest' | ||
| 41 | restart: always | ||
| 42 | ports: | ||
| 43 | # Public HTTP Port: | ||
| 44 | - '80:80' | ||
| 45 | # Public HTTPS Port: | ||
| 46 | - '443:443' | ||
| 47 | # Admin Web Port: | ||
| 48 | - '81:81' | ||
| 49 | environment: | ||
| 50 | # These are the settings to access your db | ||
| 51 | DB_MYSQL_HOST: "db" | ||
| 52 | DB_MYSQL_PORT: 3306 | ||
| 53 | DB_MYSQL_USER: "npm-user" | ||
| 54 | DB_MYSQL_PASSWORD: "41s0s3cr1t!" | ||
| 55 | DB_MYSQL_NAME: "npm" | ||
| 56 | # If you would rather use Sqlite uncomment this | ||
| 57 | # and remove all DB_MYSQL_* lines above | ||
| 58 | # DB_SQLITE_FILE: "/data/database.sqlite" | ||
| 59 | # Uncomment this if IPv6 is not enabled on your host | ||
| 60 | # DISABLE_IPV6: 'true' | ||
| 61 | volumes: | ||
| 62 | - ./data:/data | ||
| 63 | - ./letsencrypt:/etc/letsencrypt | ||
| 64 | depends_on: | ||
| 65 | - db | ||
| 66 | db: | ||
| 67 | image: 'jc21/mariadb-aria:latest' | ||
| 68 | restart: always | ||
| 69 | environment: | ||
| 70 | MYSQL_ROOT_PASSWORD: 's3cr1t' | ||
| 71 | MYSQL_DATABASE: 'npm' | ||
| 72 | MYSQL_USER: 'npm-user' | ||
| 73 | MYSQL_PASSWORD: '41s0s3cr1t!' | ||
| 74 | volumes: | ||
| 75 | - ./data/mysql:/var/lib/mysql | ||
| 76 | }}} | ||
| 77 | |||
| 78 | The content above needs to be stored in the ##docker-compose.yaml## file in the ##/opt/nginxproxymanager## directory. The commands below illustrate how to get it up and running. | ||
| 79 | |||
| 80 | (% class="box" %) | ||
| 81 | {{{mkdir /opt/nginxproxymanager | ||
| 82 | cd /opt/nginxproxymanager | ||
| 83 | cp ~/docker-compose.yaml . | ||
| 84 | docker-compose up -d | ||
| 85 | }}} | ||
| 86 | |||
| 87 | Generally this is the approach when creating other containers as well. All of the reside in the ##/opt/## filesystem and whenever possible we use ##docker-compose## command instead of ##docker run##. It is very important to have all subsequent containers be part of the same ##nginxproxymanager## network. This will be stressed again below. | ||
| 88 | |||
| 89 | == configuration == | ||
| 90 | |||
| 91 | (% style="text-align:center" %) | ||
| 92 | [[image:Nginx Proxy Manager - Configuration.png||alt="proxy hosts configuration"]] | ||
| 93 | |||
| 94 | == DNS zone file settings == | ||
| 95 | |||
| 96 | The hosts needs to be resolvable hence there should be a DNS where we can add them to the zone files. This is done at https://gandi.net | ||
| 97 | |||
| 98 | (% style="text-align:center" %) | ||
| 99 | [[image:informeer.de -Your domains - Gandi net.png||alt="informeer.de DNS records"]] | ||
| 100 | |||
| 101 | (% style="text-align:center" %) | ||
| 102 | [[image:bladzij.de -Your domains - Gandi net.png||alt="bladzij.de DNS records"]] | ||
| 103 | |||
| 104 | |||
| 105 | == Specific host settings == | ||
| 106 | |||
| 107 | === Nextcloud === | ||
| 108 | |||
| 109 | The proxymanager by default limits the size of the files that can be transferred. This is a good thing but for nextcloud you might want to bypass this setting. This can be done by opening the opening the ##edit## and select the ##advanced## tab. Then enter the stanza below: | ||
| 110 | |||
| 111 | (% class="box" %) | ||
| 112 | {{{ proxy_set_header Host $host; | ||
| 113 | proxy_set_header X-Forwarded-Proto $scheme; | ||
| 114 | proxy_set_header X-Real-IP $remote_addr; | ||
| 115 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| 116 | proxy_max_temp_file_size 16384m; | ||
| 117 | client_max_body_size 0; | ||
| 118 | }}} | ||
| 119 | |||
| 120 | references: | ||
| 121 | |||
| 122 | * https://www.reddit.com/r/unRAID/comments/ezw5jo/nginx_proxy_manager_and_nextcloud_large_file/ | ||
| 123 | * https://forum.seafile.com/t/nginx-proxy-manager-causing-failure-when-uploading-files/11492/6 | ||
| 124 | |||
| 125 | = portainer = | ||
| 126 | |||
| 127 | This is a convenient docker web-interface to docker. Together with the nginx-proxymanager these two are considered the two fundamental docker images to have available. As with other docker images it is important to put them on the same (internal) network. The following line executed as root from the ##/opt## (or oether) directory will create the desired docker container and start it daemonised. | ||
| 128 | |||
| 129 | (% class="box" %) | ||
| 130 | {{{docker run -d --network nginxproxymanager_default --restart=always --name portainer -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce | ||
| 131 | }}} | ||
| 132 | |||
| 133 | The (usual) port mapping to 8000 is removed as we don't use edge agents anyway. | ||
| 134 | |||
| 135 | |||
| 136 | = nextcloud = | ||
| 137 | |||
| 138 | Contrary to the ##portainer## instance which we created using the regular docker command line we now use ##docker-compose##. This offers more fine grain configuration possibilities. After some testing the configuration settled upon is ##docker-compose.yaml## located in ##/opt/nextcloud## and listed below. ### JBR ## are comment lines. **NB** note the space character after the hash character. | ||
| 139 | |||
| 140 | (% class="box" %) | ||
| 141 | {{{# JBR version: '2' | ||
| 142 | version: '3' | ||
| 143 | |||
| 144 | volumes: | ||
| 145 | nextcloud: | ||
| 146 | db: | ||
| 147 | |||
| 148 | networks: | ||
| 149 | default: | ||
| 150 | external: | ||
| 151 | name: nginxproxymanager_default | ||
| 152 | |||
| 153 | services: | ||
| 154 | db: | ||
| 155 | image: mariadb | ||
| 156 | restart: always | ||
| 157 | command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW | ||
| 158 | volumes: | ||
| 159 | - db:/var/lib/mysql | ||
| 160 | environment: | ||
| 161 | - MYSQL_ROOT_PASSWORD=Pf0kL6O | ||
| 162 | - MYSQL_PASSWORD="KlukKluk789MaMaLoe456!" | ||
| 163 | - MYSQL_DATABASE=nextcloud | ||
| 164 | - MYSQL_USER=nextcloud | ||
| 165 | |||
| 166 | app: | ||
| 167 | image: nextcloud | ||
| 168 | restart: always | ||
| 169 | # JBRv may not be needed in some cases e.g. proxymanagers and specific local setups | ||
| 170 | ports: | ||
| 171 | - 8080:80 | ||
| 172 | # JBR^ | ||
| 173 | links: | ||
| 174 | - db | ||
| 175 | volumes: | ||
| 176 | - nextcloud:/var/www/html | ||
| 177 | # JBRv this bind mount volume enables sharing from host with nextcloud instance. NB: permissions are governed by host! | ||
| 178 | - /data/shared_nextcloud:/on_host/data | ||
| 179 | - /home/4all/shared/nextcloud:/on_host/home_4all | ||
| 180 | # JBR^ | ||
| 181 | environment: | ||
| 182 | - MYSQL_PASSWORD="KlukKluk789MaMaLoe456!" | ||
| 183 | - MYSQL_DATABASE=nextcloud | ||
| 184 | - MYSQL_USER=nextcloud | ||
| 185 | - MYSQL_HOST=db | ||
| 186 | }}} | ||
| 187 | |||
| 188 | Please note the two mounted volumes that the host makes available to the nextcloud container. These are used by the nextcloud plugin that make external storage available to instance (external means not within the container). | ||
| 189 | |||
| 190 | (% class="box" %) | ||
| 191 | {{{/data/shared_nextcloud:/on_host/data | ||
| 192 | /home/4all/shared/nextcloud:/on_host/home_4all | ||
| 193 | }}} | ||
| 194 | |||
| 195 | (% style="text-align:center" %) | ||
| 196 | [[image:Apps-Nextcloud.png||alt="external storage app"]] | ||
| 197 | |||
| 198 | (% style="text-align:center" %) | ||
| 199 | [[image:Settings-Nextcloud.png||alt="external configuration"]] |