Confused with docker behaviour

  • Firstly, pardon my ignorance. I am unfamiliar with docker syntax.

    Following the good suggestions of fellow posters on this forum I have been able to get 2 containers up and running.

    But they are slowly and surely increasing in size, and by giant amounts without any addition of any new data. Mere reboots expand the occupied space. It is also taking its toll on my LE startup time. It runs into 5-6 minutes after 15-20 reboots.

    Someone suggested that cleaning up containers not in use might help and sure enough it does free up a lot of space.

    So why am I having so many unused containers piling up after a period of time?

    So there seem to be 2 possible solutions :

    1. seems like I have setup something wrong to begin with which causes so many redundant images to pile up or

    2. schedule the clean up command (at every reboot?)


    Can someone please help with this?
    [hr]
    Below is how I have setup docker, in case anyone can identify some flaw

    Plex, in the example below:


    1. from command I type the following lines:

    mkdir -p /storage/.kodi/userdata/.apps/plex
    chmod -R a+rwx /storage/.kodi/userdata/.apps/plex

    # docker run --net=host -d \
    -p 32400:32400 \
    -v /storage/.kodi/userdata/.apps/plex:/config \
    -v /var/media/Data:/data \
    timhaak/plex

    This starts the app. But if I reboot it does not restart.

    So I was told that ....

    2. create a service in a folder called system.d , for instance plex.service. Contents of the service file as follows:

    [Unit]
    Description=plex container
    Requires=service.system.docker.service
    After=service.system.docker.service

    [Service]
    Restart=always
    RestartSec=10s
    TimeoutStartSec=0
    ExecStartPre=-/bin/sh -c "mkdir -p /storage/.kodi/userdata/.apps/plex"
    ExecStart=/storage/.kodi/addons/service.system.docker/bin/docker run --net=host -d \
    -p 32400:32400 \
    -v /storage/.kodi/userdata/.apps/plex:/config \
    -v /var/media/Data:/data \
    timhaak/plex
    ExecStop=/storage/.kodi/addons/service.system.docker/bin/docker stop plex
    [Install]
    WantedBy=multi-user.target


    3. Thereafter, at console

    systemctl enable plex.service
    systemctl start plex.service
    journalctl -u plex.service

    Edited once, last by extremeaudio (January 20, 2017 at 1:17 PM).

  • To get rid of useless containers:

    1. Before you run the container, delete existing containers with the "docker rm ..." command.

    2. When you run the container, use the "docker run --rm ..." command, to delete the container when it is stopped.

    These commands are documented on the Docker web site.

    In my experience, solution 2 will not delete the running container if Docker exits abnormally. Solution 1 takes care of that case.


  • To get rid of useless containers:

    1. Before you run the container, delete existing containers with the "docker rm ..." command.

    2. When you run the container, use the "docker run --rm ..." command, to delete the container when it is stopped.

    These commands are documented on the Docker web site.

    In my experience, solution 2 will not delete the running container if Docker exits abnormally. Solution 1 takes care of that case.

    Do you mean I need to add the docker rm lines to the plex.service service file o created?

  • Thanks a ton. Will check and revert.

    You can also install docker addons from the linuxserver repo (plex is there). You can find the repo under libreelec addons / repositories.

    One you install, just modify the addon settings and that's it.

    There is also a docker gui manager in that repo called portainer. It lets you manage the containers and images through a web interface

    EDIT: by the way, the issue with your current method of starting plex is that it's creating a new container every time you start it, but it doesn't delete any of the old containers. So you end up with a ton of duplicates taking lots of space. You can use portainer to delete all of those and start fresh. The plex addon in the linuxserver repo manages all of that for you automatically

    Edited once, last by aptalca (January 20, 2017 at 8:31 PM).

  • You can also install docker addons from the linuxserver repo (plex is there). You can find the repo under libreelec addons / repositories.

    One you install, just modify the addon settings and that's it.

    There is also a docker gui manager in that repo called portainer. It lets you manage the containers and images through a web interface

    EDIT: by the way, the issue with your current method of starting plex is that it's creating a new container every time you start it, but it doesn't delete any of the old containers. So you end up with a ton of duplicates taking lots of space. You can use portainer to delete all of those and start fresh. The plex addon in the linuxserver repo manages all of that for you automatically


    Sounds very interesting. However I stumbled at the first step itself. I wish docker instructions were easier :(

    From command line, I issue:

    docker create \
    --name=plex \
    --net=host \
    -e VERSION=latest \
    -e PUID=0 -e PGID=0 \
    -e TZ=Asia/Kolkata \
    -v /storage/.kodi/userdata/.apps/plex:/config \
    -v /var/media/Data:/data \
    linuxserver/plex

    However I cannot open <my-ip-address>:32400/manage or <my-ip-address>:32400/web

    Secondly, portainer uses port 9000 which my Logitech media server also does. How do I change one of the two? I deploy portainer by using
    docker run -d -p 9000:9000 portainer/portainer

    If I change the port to 9001 or something, it doesnt work.

  • I don't think you read what I wrote [emoji6]

    You don't need to do anything from command line. Install the addon and the addon will manage each container for you. If you go to the addon's settings, it will let you change the port.

    Go to addons, install from repo, libreelec addons, repositories and install linuxserver repo. Then go to addons, install from repo, linuxserver repo, and install plex. Go to its settings if you want to change anything. Within a few minutes, plex will be running (it has to download the image, extract it and then create the container, which may take a few minutes)

    Make sure you delete any other plex containers that may be running in the background. Portainer will let you do that (install it from the repo, not command line)

  • I assumed exactly what you wrote but then I thought I assumed wrong cos my libreelec addons repo does not have a "repositories" sub section. Will try a update / force refresh and try again. Thanks.

    PS: any direct link to the repo zip?

    Edited once, last by extremeaudio (January 21, 2017 at 5:46 PM).


  • I assumed exactly what you wrote but then I thought I assumed wrong cos my libreelec addons repo does not have a "repositories" sub section. Will try a update / force refresh and try again. Thanks.

    PS: any direct link to the repo zip?

    Sorry it's named "Add-on Repository". If you don't see it, what platform are you on?

  • Sorry it's named "Add-on Repository". If you don't see it, what platform are you on?

    Hey there,
    Am currently using rpi2 and rpi3 with LEv.7.0.3, installing the linuxserver repo seems to be possible only if downloading the .zip file and then manually installing it.
    So far if trying the update the LibreELEC Add-ons repo it says it's up to date.

  • I'm on generic.

    Btw I installed the repo and plex by manually downloading the repo zip. Plex shows as installed. But I can't access the web interface. Don't know where to start looking. Same with portainer. Nothing at <my-ip-address>:9000

    Edited once, last by extremeaudio (January 22, 2017 at 12:25 PM).

  • Hey there,
    Am currently using rpi2 and rpi3 with LEv.7.0.3, installing the linuxserver repo seems to be possible only if downloading the .zip file and then manually installing it.
    So far if trying the update the LibreELEC Add-ons repo it says it's up to date.

    Repo shows up on LE8 alpha and betas but not 7. You're right the zip installs on 7. The reason we limited the repo to 8 is because 7 doesn't have docker support on the aarch64 platform
    [hr]


    I'm on generic.

    Btw I installed the repo and plex by manually downloading the repo zip. Plex shows as installed. But I can't access the web interface. Don't know where to start looking. Same with portainer. Nothing at <my-ip-address>:9000

    Hmm. In command line can you try the following commands and check their output?

    docker ps -a

    docker images

    systemctl status docker.linuxserver.portainer

    The first one should list all containers created and their running status
    The second will list all docker images downloaded (shows if there is a connection issue to docker hub)
    The third should show the status of the systemd file created by the portainer addon and if it failed, why it failed (my guess is that you may be out of space, in which case you can delete some containers with docker rm containername and you can get the container name from the first command above)

    Edited once, last by aptalca (January 22, 2017 at 2:34 PM).

  • The first 2 results were

    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

    and

    REPOSITORY TAG IMAGE ID CREATED SIZE


    and the last one gave the following output (couldn't grab everything). In My Addons > Services I can see both plex and portainer as enabled.


  • To get rid of useless containers:

    1. Before you run the container, delete existing containers with the "docker rm ..." command.

    2. When you run the container, use the "docker run --rm ..." command, to delete the container when it is stopped.

    These commands are documented on the Docker web site.

    In my experience, solution 2 will not delete the running container if Docker exits abnormally. Solution 1 takes care of that case.

    I am testing with docker run --rm appended to the command for now

    To see whats going on I have also switched on all notifications for the docker add on.

    I can endlessly see notifications on the screen that go:

    docker name: abc | action: create
    docker name: def | action: destroy
    docker name: ghi | action: create
    docker name: abc | action: destroy
    docker name: jkl | action: create
    docker name: ghi | action: destroy

    So it keeps creating and destroying these images.

    As of now it doesnt seem to be hogging too much space.

    Issuing docker ps -a also shows that at any point of time there arent more than 2 or 3 images in the list unlike the hundreds earlier.

    Prima facie, even the storage space occupied doesn't seem to be on the upswing.

    Does everything seem normal?

  • Hmm. In command line can you try the following commands and check their output?

    docker ps -a

    docker images

    systemctl status docker.linuxserver.portainer

    The first 2 results were

    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

    and

    REPOSITORY TAG IMAGE ID CREATED SIZE


    and the last one gave the following output (couldn't grab everything). In My Addons > Services I can see both plex and portainer as enabled.


  • Repo shows up on LE8 alpha and betas but not 7. You're right the zip installs on 7. The reason we limited the repo to 8 is because 7 doesn't have docker support on the aarch64 platform

    Thank you for letting me know, I nearly thought there was something wrong with my installs.
    Also thanks for the nice articles at linuxserver.io and the docker repo for LE :D