{"id":15576,"date":"2018-08-12T18:44:09","date_gmt":"2018-08-12T18:44:09","guid":{"rendered":"http:\/\/blog.taragana.com\/?p=15576"},"modified":"2018-10-14T12:19:01","modified_gmt":"2018-10-14T12:19:01","slug":"lxd-how-to-easily-apt-update-and-upgrade-all-running-lxd-containers","status":"publish","type":"post","link":"https:\/\/blog.taragana.com\/lxd-how-to-easily-apt-update-and-upgrade-all-running-lxd-containers-15576","title":{"rendered":"LXD: How to easily apt update and upgrade all running LXD containers"},"content":{"rendered":"

It is easy to create large number of LXD<\/strong> \/ LXC containers as it consumes minimal resources. Coupled with btrfs, it consumes minimal hard-disk space also due to de-duplication built-in within btrfs file system. Soon you would find yourself spending a significant amount of time updating (sudo apt update<\/code>) and upgrading (sudo apt -y upgrade<\/code>) all these containers (don’t forget: sudo apt -y autoremove<\/code>). Here is a simple bash-fu magic which you can run from host to update all the containers:
\nlxc -c ns --format csv ls|grep RUNNING|cut -f1 -d',' | xargs -I'{}' sh -c \"echo Updating '{}';lxc exec '{}' -- apt -qq update;lxc exec '{}' -- apt -qq -y upgrade;lxc exec '{}' -- apt -qq -y autoremove\"<\/code>
\nThe code has been tested on Ubuntu 16.04<\/strong> but it is expected to work on any Ubuntu system starting from 16.04. For previous version(s) use apt-get<\/code> instead of apt<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"

It is easy to create large number of LXD \/ LXC containers as it consumes minimal resources. Coupled with btrfs, it consumes minimal hard-disk space also due to de-duplication built-in within btrfs file system. Soon you would find yourself spending a significant amount of time updating (sudo apt update) and upgrading (sudo apt -y upgrade) […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10,13],"tags":[18,137],"_links":{"self":[{"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/posts\/15576"}],"collection":[{"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/comments?post=15576"}],"version-history":[{"count":1,"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/posts\/15576\/revisions"}],"predecessor-version":[{"id":15818,"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/posts\/15576\/revisions\/15818"}],"wp:attachment":[{"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/media?parent=15576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/categories?post=15576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.taragana.com\/wp-json\/wp\/v2\/tags?post=15576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}