Giter VIP home page Giter VIP logo

docker-hd-idle's Introduction

docker-hd-idle

Bundle hd-idle application to run in a docker environment.

buy-me-a-coffee

Like some of my work? Buy me a coffee โ˜• (or more likely a beer ๐Ÿบ, or even more likly shoes ๐Ÿ‘  or purse ๐Ÿ‘œ for the wify ๐Ÿ˜„)

Buy Me A Coffee

Description

hd-idle is a utility program for spinning-down external disks after a period of idle time. Since most external IDE disk enclosures don't support setting the IDE idle timer, a program like hd-idle is required to spin down idle disks automatically.

The goal of this docker image is to make the use of hd-idle an easy. The configuration of the application can either be done via environment variables or via a config file in a mounted volume.

Implementations

The image implements the 2 available hd-idle versions:

  1. The Golang implementation by Andoni del Olmo. The documentation and source code can be found on Github repository page.

  2. The orignal (legacy) implementation by Christina Mueller. The documentation can be found on the Sourceforge page. This version can be used by setting LEGACY=1 environment variable.

For any configuartion topics concerning hd-idle I recommend visiting either project site.

Many thanks to to both of them for this great tool!

Supported tags and respective Dockerfile links

  • 1.2.2, latest: Golang version 1.13 and legacy version 1.05

  • dev: Development build

Word of cautions

In order to set the disks in stand-by the container needs to be in privileged mode and the /dev path has to be forwarded to the container. Of course that could be a potential security risk. For me personally, I can live with it in my homelab setup.

Run

Basic run command to get things up and running

docker run -d \
  --name hd-idle \
  --privileged \
  -v /dev:/dev \
  tekgator/docker-hd-idle:latest

This will run the container with default settings, no configuration possible. All Hard drives will spin down after 10 minutes inactivity.

Configuration option 1: Map to volume

docker run -d \
  --name hd-idle \
  --privileged \
  -v /dev:/dev \
  -v /path_to_config/hd-idle:/config \
  tekgator/docker-hd-idle:latest

On first start of the container it will create a config file in the provided volume. Make adjustments as described in the hd-idle documentation and restart the container afterwards to apply the changes.

Configuration option 2: Setting environment variables

docker run -d \
  --name hd-idle \
  --privileged \
  -v /dev:/dev \
  -e IDLE_TIME='0' \ # Optional: set default stand-by for all disks, e.g. 0 for turn off
  -e DISK_ID1='/dev/disk/by-uuid/994dffb1-96f0-4440-9ee1-4711' \
  -e IDLE_TIME1='900' \ # Optional (default 600s): if disk is idle 900s go into stand-by
  -e DISK_CMD1='ata' \ # Optional (default: scsi): which API to use to communicate with the device (not evaluated in legacy version)
  -e DISK_ID2='/dev/disk/by-uuid/fa376393-91e4-4d9f-8914-4712' \
  tekgator/docker-hd-idle:latest

Configurations for certain disks can be made by utilizing environment variables. For each disk setting just increase the number on the variable, e.g. if you like to add a third disk to the config just add DISK_ID3 and so on.

In this example we are creating the following config:

  • Turn off stand-by for all disks by using IDLE_TIME='0'
  • Create a special stand-by rule for DISK_ID1='/dev/disk/by-uuid/994dffb1-96f0-4440-9ee1-4711' with stand-by time after 15 minutes by utilizting IDLE_TIME1='900'. To set the disk into stand-by the ATA command set is used DISK_CMD1=ata.
  • Create a special stand-by rule for DISK_ID2='/dev/disk/by-uuid/fa376393-91e4-4d9f-8914-4712' with stand-by time after 10 minutes as default time.

Configuration option 3: Utilize config file and environment together

Just combine option 1 and 2 togehter. At first start up a config file is created in the mounted volume with the passed environment variables. Afterwards the config file can be adjusted to your needs. As mentioned already the config file will be parsed on container startup.

Legacy version

If you like to use the legacy hd-idle version you can achive this by setting the environment variable LEGACY=1 like so:

docker run -d \
  --name hd-idle \
  --privileged \
  -v /dev:/dev \
  -e LEGACY='1' \
  tekgator/docker-hd-idle:latest

Note: If you previously utilized the flags -c and -s from the Golang version it needs to be removed from the config. Otherwise legacy hd-idle will not start. But this can also be seen in the log.

Use with docker-compose

A sample docker-compose file can be found within the repository. Also the test cases are worth a look.

  hd-idle:
    image: tekgator/docker-hd-idle:latest
    container_name: hd-idle
    privileged: true
    environment:
      # LEGACY: 1    #uncomment to use legacy version of hd-idle
      IDLE_TIME: 0
      DISK_ID1: /dev/disk/by-uuid/994dffb1-96f0-4440-9ee1-4711
      DISK_CMD1: ata
      IDLE_TIME1: 900
      DISK_ID2: /dev/disk/by-uuid/fa376393-91e4-4d9f-8914-4712
    volumes:
      - /dev:/dev
      - ./config:/config
    restart: unless-stopped

Additional info

  • Shell access whilst the container is running: docker exec -it hd-idle /bin/bash
  • To monitor the logs of the container in realtime: docker logs -f hd-idle

docker-hd-idle's People

Contributors

tekgator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

dreadkopp

docker-hd-idle's Issues

error when starting container

When I deploy this the container keeps restarting with error:

standard_init_linux.go:228: exec user process caused: exec format error

Using it on pine64, with OMV, docker, portainer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.