btcpayserver / btcpayserver-docker

Docker resources for hosting BTCPayServer easily
MIT License
583 stars 358 forks source link

BTCPay Deleted/Untagged Unrelated Docker Images when running btcpay-update.sh #281

Open maltokyo opened 4 years ago

maltokyo commented 4 years ago

It doesnt matter as they are non-critical for me, but when I ran btcpay-update.sh today, it deleted/untagged a bunch of non-BTCPay related docker images.

See "Deleted Images" section at the end. Is it normal/ok?

Result of: # btcpay-update.sh

remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (5/5), done.
From https://github.com/btcpayserver/btcpayserver-docker
   4f75f19..2da700d  master     -> origin/master
Updating 4f75f19..2da700d
Fast-forward
 docker-compose-generator/docker-fragments/opt-add-btctransmuter.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Using default tag: latest
latest: Pulling from btcpayserver/docker-compose-generator
Digest: sha256:9f90dfe2abf4f9f4d3b1184349ad08237548dfb9a7098ff704d887500c8746ff
Status: Image is up to date for btcpayserver/docker-compose-generator:latest
docker.io/btcpayserver/docker-compose-generator:latest
Crypto: btc
Lightning: lnd
ReverseProxy: nginx
Generating /app/Generated/docker-compose.generated.yml
Selected fragments:
    nginx
    btcpayserver
    bitcoin
    bitcoin-lnd
    opt-add-electrumx
    opt-add-pihole
    opt-more-memory
    opt-txindex
    btcpayserver-nginx
    postgres
    nbxplorer
    nginx-https
    opt-add-tor
Generated /app/Generated/pull-images.sh
Generated /app/Generated/save-images.sh
Generated /app/Generated/docker-compose.generated.yml

Installed bitcoin-cli.sh to /usr/local/bin: Command line for your Bitcoin instance
Installed bitcoin-lncli.sh to /usr/local/bin: Command line for your Bitcoin LND instance
Installed pihole.sh to /usr/local/bin: Command line for running pihole commands
Installed btcpay-clean.sh to /usr/local/bin: Command line for deleting old unused docker images
Installed btcpay-down.sh to /usr/local/bin: Command line for stopping all services related to BTCPay Server
Installed btcpay-restart.sh to /usr/local/bin: Command line for restarting all services related to BTCPay Server
Installed btcpay-setup.sh to /usr/local/bin: Command line for restarting all services related to BTCPay Server
Installed btcpay-up.sh to /usr/local/bin: Command line for starting all services related to BTCPay Server
Installed btcpay-admin.sh to /usr/local/bin: Command line for some administrative operation in BTCPay Server
Installed btcpay-update.sh to /usr/local/bin: Command line for updating your BTCPay Server to the latest commit of this repository
Installed changedomain.sh to /usr/local/bin: Command line for changing the external domain of your BTCPay Server
Creating network "generated_default" with the default driver
Creating generated_bitcoin_rtl_1 ... done
Creating tor                     ... done
Creating generated_electrumx_1   ... done
Creating generated_postgres_1    ... done
Creating generated_nbxplorer_1   ... done
Creating pihole                  ... done
Creating btcpayserver_bitcoind   ... done
Creating tor-gen                  ... done
Creating btcpayserver_lnd_bitcoin ... done
Creating nginx                    ... done
Creating generated_btcpayserver_1 ... done
Creating nginx-gen                ... done
Creating letsencrypt-nginx-proxy-companion ... done
Deleted Images:
untagged: dperson/samba:latest
untagged: dperson/samba@sha256:ffbca71bee5396195df4987acd87dca4fbb66906a9888783193fe57ca9854acc
deleted: sha256:7be9f2690bc1ff7c83b1c8dccab2f630bde7b7eea8b79f6faca7e12952caa053
deleted: sha256:e02d6be1da8941725c8316ac90ad2db8cf4ae2e8f70cd71331fa4b14793c27b7
deleted: sha256:ae7293f324656e0c4a5f8908043c2408b5ff94bd1bebd523aa4c27fca5ea50ed
deleted: sha256:77cae8ab23bf486355d1b3191259705374f4a11d483b24964d2f729dd8c076a0
untagged: vladgh/minidlna:latest
untagged: vladgh/minidlna@sha256:0bb5ce08e456da491463f6363fda55891ec53ac828389a3621093bdfa667fc8a
deleted: sha256:75e59a20d1c993bc32ae201202ce1b2477415ecc56a42142053004699af20db5
deleted: sha256:17d9529a669ce72015d93f167bfca44bf12ed5cd85373db524f5da85d064b81d
deleted: sha256:7aacf6924d591ab447c196e6db6514a18fe7e288beb8d0965bc34c6809ee263f
deleted: sha256:531743b7098cb2aaf615641007a129173f63ed86ca32fe7b5a246a1c47286028
NicolasDorier commented 4 years ago

Yes. We are automatically deleting images that are not used anymore after update to prevent storage to grow definitively. There is sadly no way of doing it at a finer level than just tell docker to prune everything that is not used.

maltokyo commented 4 years ago

OK, I thought we could use labels for system prune, let me investigate a bit.

NicolasDorier commented 4 years ago

@maltokyo problem with label is that we would need to put them in the 30 differents docker images we use :D

bitodt commented 4 years ago

Pruning aside, it also restarts all docker containers (!!) and stops some.

Maybe there should be a disclaimer to run it sandboxed in its own machine, without other services.

The whole point of docker is to run separate services without them intervening with each other. This deployment does the exact opposite.

It started old (stopped) containers I had, and stopped my important services from running!

My server is a mess and I now have to spend hours fixing the damage...

I appreciate BTCPayServer and the development that has been done, as well as the automation you have created for deploying.

But please, add a huge big disclaimer that this interferes with other docker deployments on the machine!

maltokyo commented 4 years ago

@orfeas0 - There is nothing in the btcpay-update.sh script which would stop containers, as far as I can see. Which line would do that?

The only command that would affect non-BTCPay Server stuff is docker image prune -af --filter "label!=org.btcpayserver.image=docker-compose-generator" and this certainly wont stop anything else, it will only remove unused images.

bitodt commented 4 years ago

My bad, this was the result of btcpay-setup.sh, not btcpay-update.sh.

maltokyo commented 4 years ago

Which part of setup would stop other containers? I don't get it.

Eskyee commented 4 years ago

https://docs.docker.com/config/pruning/ Never had problems with a btcpay-setup.sh

bitodt commented 4 years ago

My guess is this:

if ! [[ -f "/etc/docker/daemon.json" ]] && [ -w "/etc/docker" ]; then
        echo "{
\"log-driver\": \"json-file\",
\"log-opts\": {\"max-size\": \"5m\", \"max-file\": \"3\"}
}" > /etc/docker/daemon.json
        echo "Setting limited log files in /etc/docker/daemon.json"
        $SYSTEMD_RELOAD && $START && systemctl restart docker
    fi

    echo -e "BTCPay Server systemd configured in /etc/systemd/system/btcpayserver.service\n"
    if $SYSTEMD_RELOAD; then
        systemctl daemon-reload

It restarts the docker daemon and reloads systemctl daemon.

I don't understand why we're messing with systemctl. Isn't a "docker-compose up" enough to keep a service running?

I repeat: That's what docker is for: Containerization, separation of apps&services, sandboxing.

A "docker deployment" of an application should not mess with the host OS, at all!

NicolasDorier commented 4 years ago

@orfeas0 we can add arguments to the scripts to prevent that. Those lines have been added as people started crashing after undefined period of time as the logs were growing without any control. (this happen fast, especially if some container is running a tight loop logging a lot for a bug, bringing the whole system down)