Is Docker a good option for running legacy software in a current OS?

Hi, I’m very new to Docker and wanted to make sure I am on the right path before diving in too deep.

I am moving my main desktop from Debian Wheezy (#!) to Arch Linux. One of the items I need to port over is a cron script that uses a utility called ledger to mine data from a GnuCash file, generate charts of spending vs budget, and emails them to my wife and I each morning. The latest version of ledger (and the only one available for Arch) does not support GnuCash files any longer, and I must install an older version which is still supported in terms of libraries on Wheezy.

I cannot get it to run in Arch. I don’t want this issue to be a blocking point. I am wondering if I can use Docker to run this script with it’s dependencies in a Wheezy-based Docker container. I think I would need to:

  • Get a Wheezy container installed
  • Install ledger 2.6 with proper dependencies
  • Map a local drive (containing my GnuCash data file) in the container so I can access it
  • Map a local drive for outputting the images.
  • Execute the script via Docker with my host cron

The script also sends the email via Gmail. Not sure if I would want to keep that in the container or just let Docker handle the stuff I can’t do in Arch and keep the rest there.

If anybody more experienced can weigh in on the suitability and feasibility of this, it would be much appreciated. Any tips would be even better. For now I’m poring through the docs.

Thanks!

Hi,

Jessie Frazelle has a great blog post about containerizing desktop apps with a link to her Dockerfiles: https://blog.jessfraz.com/post/docker-containers-on-the-desktop/

It should be possible to do what you’re describing.

Thanks,

Jerry

1 Like

I meant to mention you can mount host directories or files:

Hello!

This is indeed a very valid use case for docker.

Your Dockerfile might look something like this:

FROM debian:wheezy
RUN apt-get install ledger-2.6 # assuming this is what you need to get ledger installed

you could use that to build an image called ledger: docker build -t ledger .

Assuming the normal ledger command is something like ledger /path/to/gnucash.dat -o /images/, you could run it something like this:

docker run -it -v /path/to/gnucash.dat:/gnucash.dat -v /path/to/images/:images ledger ledger /gnucash.dat -o /images

Your cron script on the host could call ledger using the docker run command, and then email the results. You could also do the email bit inside the container.

Hopefully this helps!

Thanks to all, what a responsive and helpful community!

I hope to try this in the next few days .

Best regards,

Bill

Pulled debian:wheezy, entered it with /bin/bash and installed ledger and vim. Committed it. Figured out my drive mapping and it runs like a champ! Just need to coordinate the cron between what I put in the image and what runs outside. I’ll search on how to create / use the right user in the image so the files I spit out aren’t owned by root.

This is fantastic technology! I can stay bleeding edge with Arch without giving up the old and stable. Thanks again for your help.

One final note, everything works but it took me 45 minutes of Googling to figure out why my docker run command would not execute with cron, and would leave no trace in the logs.

I had to remove the -t option from my command if starting with cron. With the -t in there, it would fail without any trace. Everything I found when searching was related to running cron INSIDE a container, but nothing addressing executing a docker command within the host cron.

Ah yes, the -t option allocates a pseudo-tty, which cron does not have. If I do something like echo | docker run -it ubuntu cat, it will complain and say FATA[0000] cannot enable tty mode on non tty input. I’m not sure why cron wouldn’t have the same error message though.