2023-07-09 20:45:16 +00:00
<!doctype html> < html lang = en class = no-js > < head > < meta charset = utf-8 > < meta name = viewport content = "width=device-width,initial-scale=1" > < meta name = description content = "Welcome to the home of the LinuxServer.io documentation!" > < meta name = author content = LinuxServer.io > < link href = https://docs.linuxserver.io/general/container-customization/ rel = canonical > < link href = ../running-our-containers/ rel = prev > < link href = ../docker-compose/ rel = next > < link rel = icon href = "https://gblobscdn.gitbook.com/spaces%2F-LWuIse8qFJj2MqDi90T%2Favatar-1590244439115.png?alt=media" > < meta name = generator content = "mkdocs-1.4.3, mkdocs-material-9.1.17" > < title > Customizing LinuxServer Containers - LinuxServer.io< / title > < link rel = stylesheet href = ../../assets/stylesheets/main.26e3688c.min.css > < link rel = stylesheet href = ../../assets/stylesheets/palette.ecc896b0.min.css > < link rel = preconnect href = https://fonts.gstatic.com crossorigin > < link rel = stylesheet href = "https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback" > < style > : root { --md-text-font : "Roboto" ; --md-code-font : "Roboto Mono" } < / style > < script > _ _md _scope = new URL ( "../.." , location ) , _ _md _hash = e => [ ... e ] . reduce ( ( e , _ ) => ( e << 5 ) - e + _ . charCodeAt ( 0 ) , 0 ) , _ _md _get = ( e , _ = localStorage , t = _ _md _scope ) => JSON . parse ( _ . getItem ( t . pathname + "." + e ) ) , _ _md _set = ( e , _ , t = localStorage , a = _ _md _scope ) => { try { t . setItem ( a . pathname + "." + e , JSON . stringify ( _ ) ) } catch ( e ) { } } < / script > < / head > < body dir = ltr data-md-color-scheme = default data-md-color-primary = purple data-md-color-accent = indigo > < script > var palette = _ _md _get ( "__palette" ) ; if ( palette && "object" == typeof palette . color ) for ( var key of Object . keys ( palette . color ) ) document . body . setAttribute ( "data-md-color-" + key , palette . color [ key ] ) < / script > < input class = md-toggle data-md-toggle = drawer type = checkbox id = __drawer autocomplete = off > < input class = md-toggle data-md-toggle = search type = checkbox id = __search autocomplete = off > < label class = md-overlay for = __drawer > < / label > < div data-md-component = skip > < a href = #customizing-linuxserver-containers class = md-skip > Skip to content < / a > < / div > < div data-md-component = announce > < / div > < header class = "md-header md-header--shadow" data-md-component = header > < nav class = "md-header__inner md-grid" aria-label = Header > < a href = ../.. title = LinuxServer.io class = "md-header__button md-logo" aria-label = LinuxServer.io data-md-component = logo > < img src = "https://gblobscdn.gitbook.com/spaces%2F-LWuIse8qFJj2MqDi90T%2Favatar-1590244439115.png?alt=media" alt = logo > < / a > < label class = "md-header__button md-icon" for = __drawer > < svg xmlns = http://www.w3.org/2000/svg viewbox = "0 0 24 24" > < path d = "M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z" / > < / svg > < / label > < div class = md-header__title data-md-component = header-title > < div class = md-header__ellipsis > < div class = md-header__topic > < span class = md-ellipsis > LinuxServer.io < / span > < / div > < div class = md-header__topic data-md-component = header-topic > < span class = md-ellipsis > Customizing LinuxServer Containers < / span > < / div > < / div > < / div > < form class = md-header__option data-md-component = palette > < input class = md-option data-md-color-media = "(prefers-color-scheme: light)" data-md-color-scheme = default data-md-color-primary = purple data-md-color-accent = indigo aria-label = "Switch to dark mode" type = radio name = __palette id = __palette_1 > < label class = "md-header__button md-icon" title = "Switch to dark mode" for = __palette_2 hidden > < svg xmlns = http://www.w3.org/2000/svg viewbox = "0 0 24 24" > < path d = "M17 6H7c-3.31 0-6 2.69-6 6s2.69 6 6 6h10c3.31 0 6-2.69 6-6s-2.69-6-6-6zm0 10H7c-2.21 0-4-1.79-4-4s1.79-4 4-4h10c2.21 0 4 1.79 4 4s-1.79 4-4 4zM7 9c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z" / > < / svg > < / label > < input class = md-option data-md-color-media = "(prefers-color-scheme: dark)" data-md-color-scheme = slate data-md-color-primary = purple data-md-color-accent = indigo aria-label = "Switch to light mode" type = radio name = __palette id = __palette_2 > < label class = "md-header__button md-icon" title = "Switch to light mode" for = __palette_1 hidden > < svg xmlns = http://www.w3.org/2000/svg viewbox = "0 0 24 24" > < path d = "M17 7H7a5 5 0 0 0-5 5 5 5 0
2023-01-08 13:57:31 +00:00
< span class = w > < / span > < span class = nt > bar< / span > < span class = p > :< / span >
< span class = w > < / span > < span class = nt > volumes< / span > < span class = p > :< / span >
< span class = w > < / span > < span class = "p p-Indicator" > -< / span > < span class = w > < / span > < span class = "l l-Scalar l-Scalar-Plain" > /home/foo/appdata/bar:/config< / span >
< span class = w > < / span > < span class = "p p-Indicator" > -< / span > < span class = w > < / span > < span class = "l l-Scalar l-Scalar-Plain" > /home/foo/appdata/my-custom-files:/custom-cont-init.d:ro< / span >
< / code > < / pre > < / div > < p > if using compose. Where possible, to improve security, we recommend mounting them read-only (< code > :ro< / code > ) so that container processes cannot write to the location.< / p > < p > One example use case is our Piwigo container has a plugin that supports video, but requires ffmpeg to be installed. No problem. Add this bad boy into a script file (can be named anything) and you're good to go.< / p > < div class = highlight > < pre > < span > < / span > < code > < span class = ch > #!/bin/bash< / span >
2022-12-02 02:14:39 +00:00
2023-01-08 13:57:31 +00:00
< span class = nb > echo< / span > < span class = w > < / span > < span class = s2 > " **** installing ffmpeg ****" < / span >
apk< span class = w > < / span > add< span class = w > < / span > --no-cache< span class = w > < / span > ffmpeg
< / code > < / pre > < / div > < p > < strong > NOTE:< / strong > The folder < code > /custom-cont-init.d< / code > needs to be owned by root! If this is not the case, this folder will be renamed and a new (empty) folder will be created. This is to prevent remote code execution by putting scripts in the aforementioned folder.< / p > < h2 id = custom-services > Custom Services< / h2 > < p > There might also be a need to run an additional service in a container alongside what we already package. Similarly to the custom scripts, just create a new directory at < code > /custom-services.d< / code > . The files in this directory should be named after the service they will be running. Similar to with custom scripts you will need to mount this folder like any other volume if you wish to make use of it. e.g. < code > -v /home/foo/appdata/my-custom-services:/custom-services.d< / code > if using the Docker CLI or< / p > < div class = highlight > < pre > < span > < / span > < code > < span class = nt > services< / span > < span class = p > :< / span >
< span class = w > < / span > < span class = nt > bar< / span > < span class = p > :< / span >
< span class = w > < / span > < span class = nt > volumes< / span > < span class = p > :< / span >
< span class = w > < / span > < span class = "p p-Indicator" > -< / span > < span class = w > < / span > < span class = "l l-Scalar l-Scalar-Plain" > /home/foo/appdata/bar:/config< / span >
< span class = w > < / span > < span class = "p p-Indicator" > -< / span > < span class = w > < / span > < span class = "l l-Scalar l-Scalar-Plain" > /home/foo/appdata/my-custom-services:/custom-services.d:ro< / span >
< / code > < / pre > < / div > < p > if using compose. Where possible, to improve security, we recommend mounting them read-only (< code > :ro< / code > ) so that container processes cannot write to the location.< / p > < p > Running cron in our containers is now as simple as a single file. Drop this script in < code > /custom-services.d/cron< / code > and it will run automatically in the container:< / p > < div class = highlight > < pre > < span > < / span > < code > < span class = ch > #!/usr/bin/with-contenv bash< / span >
2022-12-02 02:14:39 +00:00
2023-01-08 13:57:31 +00:00
/usr/sbin/crond< span class = w > < / span > -f< span class = w > < / span > -S< span class = w > < / span > -l< span class = w > < / span > < span class = m > 0< / span > < span class = w > < / span > -c< span class = w > < / span > /etc/crontabs
< / code > < / pre > < / div > < p > < strong > NOTE:< / strong > With this example, you will most likely need to have cron installed via a custom script using the technique in the previous section, and will need to populate the crontab.< / p > < p > < strong > NOTE:< / strong > The folder < code > /custom-services.d< / code > needs to be owned by root! If this is not the case, this folder will be renamed and a new (empty) folder will be created. This is to prevent remote code execution by putting scripts in the aforementioned folder.< / p > < h2 id = docker-mods > Docker Mods< / h2 > < p > In most cases if you needed to write some kind of custom logic to get a plugin to work or to use some kind of popular external service you will not be the only one that finds this logic useful.< / p > < p > If you would like to publish and support your hard work we provide a system for a user to pass a single environment variable to the container to ingest your custom modifications.< / p > < p > We consume Mods from Dockerhub and in order to publish one following our guide, you only need a Github Account and a Dockerhub account. < a href = https://github.com/linuxserver/docker-mods > (Our guide and example code can be found here)< / a > < / p > < p > Essentially it is a system that stashes a tarball of scripts and any other files you need in an image layer on Dockerhub. When we spin up the container we will download this tarball and extract it to /.< / p > < p > This allows community members to publish a relatively static pile of logic that will always be applied to an end user's up to date Linuxserver.io container.< / p > < p > An example of how this logic can be used to greatly expand the functionality of our base containers would be to add VPN support to a Transmission container:< / p > < div class = highlight > < pre > < span > < / span > < code > docker< span class = w > < / span > create< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > --name< span class = o > =< / span > transmission< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > --cap-add< span class = o > =< / span > NET_ADMIN< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > -e< span class = w > < / span > < span class = nv > PUID< / span > < span class = o > =< / span > < span class = m > 1000< / span > < span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > -e< span class = w > < / span > < span class = nv > PGID< / span > < span class = o > =< / span > < span class = m > 1000< / span > < span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > -e< span class = w > < / span > < span class = nv > DOCKER_MODS< / span > < span class = o > =< / span > taisun/config-mods:pia< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > -e< span class = w > < / span > < span class = nv > PIAUSER< / span > < span class = o > =< / span > pmyuser< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > -e< span class = w > < / span > < span class = nv > PIAPASS< / span > < span class = o > =< / span > mypassword< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > -e< span class = w > < / span > < span class = nv > PIAENDPOINT< / span > < span class = o > =< / span > < span class = s2 > " US New York City" < / span > < span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > -e< span class = w > < / span > < span class = nv > TZ< / span > < span class = o > =< / span > US/Eastern< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > -p< span class = w > < / span > < span class = m > 9091< / span > :9091< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > -p< span class = w > < / span > < span class = m > 51413< / span > :51413< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > -p< span class = w > < / span > < span class = m > 51413< / span > :51413/udp< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > -v< span class = w > < / span > path< span class = w > < / span > to< span class = w > < / span > data:/config< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > -v< span class = w > < / span > path< span class = w > < / span > to< span class = w > < / span > downloads:/downloads< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > -v< span class = w > < / span > path< span class = w > < / span > to< span class = w > < / span > watch< span class = w > < / span > folder:/watch< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > --restart< span class = w > < / span > unless-stopped< span class = w > < / span > < span class = se > \< / span >
< span class = w > < / span > linuxserver/transmission
2023-06-26 03:08:05 +00:00
< / code > < / pre > < / div > < p > The source code for this mod can be found < a href = https://github.com/Taisun-Docker/config-mods/tree/master/pia > here< / a > .< / p > < p > < strong > NOTE:< / strong > When pulling in logic from external sources practice caution and trust the sources/community you get them from, as there are extreme security implications to consuming files from sources outside of our control.< / p > < h2 id = we-are-here-to-help > We are here to help< / h2 > < p > If you are interested in writing custom logic and possibly sharing it with the community in the form of a < a href = https://github.com/linuxserver/docker-mods > Docker Mod< / a > we are always available to help you out.< / p > < p > Our < a href = https://discord.gg/YWrKVTn > Discord server< / a > is best for quick direct contact and our < a href = https://discourse.linuxserver.io/ > Forum< / a > for a longer running project.< / p > < p > There is zero barrier to entry for these levels of container customization and you are in complete control.< / p > < p > We are looking forward to your next creation.< / p > < / article > < / div > < / div > < / main > < footer class = md-footer > < div class = "md-footer-meta md-typeset" > < div class = "md-footer-meta__inner md-grid" > < div class = md-copyright > < div class = md-copyright__highlight > Copyright © 2022 LinuxServer.io < / div > Made with < a href = https://squidfunk.github.io/mkdocs-material/ target = _blank rel = noopener > Material for MkDocs < / a > < / div > < div class = md-social > < a href = https://github.com/linuxserver target = _blank rel = noopener title = github.com class = md-social__link > < svg xmlns = http://www.w3.org/2000/svg viewbox = "0 0 448 512" > <!-- Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --> < path d = "M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zM277.3 415.7c-8.4 1.5-11.5-3.7-11.5-8 0-5.4.2-33 .2-55.3 0-15.6-5.2-25.5-11.3-30.7 37-4.1 76-9.2 76-73.1 0-18.2-6.5-27.3-17.1-39 1.7-4.3 7.4-22-1.7-45-13.9-4.3-45.7 17.9-45.7 17.9-13.2-3.7-27.5-5.6-41.6-5.6-14.1 0-28.4 1.9-41.6 5.6 0 0-31.8-22.2-45.7-17.9-9.1 22.9-3.5 40.6-1.7 45-10.6 11.7-15.6 20.8-15.6 39 0 63.6 37.3 69 74.3 73.1-4.8 4.3-9.1 11.7-10.6 22.3-9.5 4.3-33.8 11.7-48.3-13.9-9.1-15.8-25.5-17.1-25.5-17.1-16.2-.2-1.1 10.2-1.1 10.2 10.8 5 18.4 24.2 18.4 24.2 9.7 29.7 56.1 19.7 56.1 19.7 0 13.9.2 36.5.2 40.6 0 4.3-3 9.5-11.5 8-66-22.1-112.2-84.9-112.2-158.3 0-91.8 70.2-161.5 162-161.5S388 165.6 388 257.4c.1 73.4-44.7 136.3-110.7 158.3zm-98.1-61.1c-1.9.4-3.7-.4-3.9-1.7-.2-1.5 1.1-2.8 3-3.2 1.9-.2 3.7.6 3.9 1.9.3 1.3-1 2.6-3 3zm-9.5-.9c0 1.3-1.5 2.4-3.5 2.4-2.2.2-3.7-.9-3.7-2.4 0-1.3 1.5-2.4 3.5-2.4 1.9-.2 3.7.9 3.7 2.4zm-13.7-1.1c-.4 1.3-2.4 1.9-4.1 1.3-1.9-.4-3.2-1.9-2.8-3.2.4-1.3 2.4-1.9 4.1-1.5 2 .6 3.3 2.1 2.8 3.4zm-12.3-5.4c-.9 1.1-2.8.9-4.3-.6-1.5-1.3-1.9-3.2-.9-4.1.9-1.1 2.8-.9 4.3.6 1.3 1.3 1.8 3.3.9 4.1zm-9.1-9.1c-.9.6-2.6 0-3.7-1.5s-1.1-3.2 0-3.9c1.1-.9 2.8-.2 3.7 1.3 1.1 1.5 1.1 3.3 0 4.1zm-6.5-9.7c-.9.9-2.4.4-3.5-.6-1.1-1.3-1.3-2.8-.4-3.5.9-.9 2.4-.4 3.5.6 1.1 1.3 1.3 2.8.4 3.5zm-6.7-7.4c-.4.9-1.7 1.1-2.8.4-1.3-.6-1.9-1.7-1.5-2.6.4-.6 1.5-.9 2.8-.4 1.3.7 1.9 1.8 1.5 2.6z" / > < / svg > < / a > < a href = https://gitlab.com/linuxserver.io target = _blank rel = noopener title = gitlab.com class = md-social__link > < svg xmlns = http://www.w3.org/2000/svg viewbox = "0 0 448 512" > <!-- Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --> < path d = "M48 32h352c26 . 5 0 48 21 . 5 48 48v352c0 26 . 5-21 . 5 48-48 48H48c-26 . 5 0-48-21 . 5-48-48V80c0-26 . 5 21 . 5-48 48-48zm334 . 1 192 . 9-44 . 6-116 . 4c- . 9-2 . 3-2 . 6-4 . 3-4 . 6-5 . 6-1 . 6-1-3 . 4-1 . 6-5 . 2-1 . 8-1 . 8- . 2-3 . 7 . 1-5 . 4 . 7-1 . 7 . 7-3 . 3 1 . 7-4 . 5 3 . 1-1 . 2 1 . 4-2 . 1 3-2 . 6 4 . 8L285 201 . 9H162 . 1l-29 . 2-92 . 2c- . 5-1 . 8-1 . 5-3 . 4-2 . 7-4 . 8-2 . 1-1 . 3-2 . 8-2 . 4-4 . 5-3-2 . 6- . 7-3 . 6-1 . 8-5 . 4- . 8-1 . 8 . 2-3 . 6 . 8-5 . 2 1 . 8-2 1 . 3-3 . 6 3 . 3-4 . 5 5 . 6L65 . 94 224 . 9l- . 47 1 . 2a82 . 94 82 . 94 0 0 0-2 . 25 52 . 5c4 . 96 17 . 3 15 . 4 32 . 5 29 . 75 43 . 3l . 17 . 1 . 38 . 3 67 . 88 50 . 9 54 . 2 40