Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help with creating my fist container

Featured Replies

I would post this in the development forum but I don't have access (as expected) so I figured this would be the next best place.

 

I'm trying to create my first container and it doesn't really get much simpler than what I am trying to accomplish.  All I want to do is create a container that will have the necessary Perl bits to be able to run the zap2xml.pl script (found here:  http://zap2xml.awardspace.info/).  I stole most of the Perl dependencies from the ddclient container but I am not even getting far enough to see if I included the right bits.  I can't even get the zap2xml.pl file to copy down to the container.  :(

 

Here is what I have:

 

I created a Docker repo:  https://hub.docker.com/r/johnodon/zap2xml/

 

which has an automated build link (turned off) to...

 

Github repo:  https://github.com/johnodon/zap2xml

 

I am able to successfully build the container but when I docker exec into it I can see the /zap2xml folder was created but the zap2xml.pl file is not there.

 

What am I doing wrong?  Here is my Dockerfile:

 

FROM phusion/baseimage:0.9.16

# Set correct environment variables
ENV DEBIAN_FRONTEND=noninteractive HOME="/root" TERM=xterm

# Use baseimage-docker's init system
CMD ["/sbin/my_init"]

# source dir
#RUN mkdir -p /zap2xml

# get zap2xml.pl 
COPY ./src/zap2xml.pl /zap2xml/

# Fix permissions of user nobody to suit unraid
RUN usermod -u 99 nobody && \
usermod -g 100 nobody  && \

# install dependencies
apt-get update -qq && \
apt-get install wget libio-socket-inet6-perl libio-socket-ssl-perl libnet-libidn-perl libnet-ssleay-perl libsocket6-perl ssl-cert libio-socket-ip-perl libjson-any-perl sasl2-bin libsasl2-modules -qy && \

#clean up
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
/usr/share/man /usr/share/groff /usr/share/info \
/usr/share/lintian /usr/share/linda /var/cache/man && \
(( find /usr/share/doc -depth -type f ! -name copyright|xargs rm || true )) && \
(( find /usr/share/doc -empty|xargs rmdir || true ))

 

I've tried COPY and ADD from the github source and directly from the hosting website.  I tried creating the destination folder first and not. 

 

I'm lost and I am sure it is something completely stupid!

 

John

I use ADD for mine and specify the full path ie :-

 

ADD sdelete.php /var/www/html/sdelete.php

 

 

  • Author

I got it to ADD the file but I couldn't add it to the 'zap2xml' folder.  When I changed to code to add it to /home, it worked fine.  Permissions issue?

 

John

Have you created the directory?

 

RUN mkdir -p /zap2xml

  • Author

I tried both ways...creating the folder first and having the ADD function create it when it copies the files.  In both cases that folder is there but empty.

No idea...  I got it to work just fine :-

 

https://github.com/cdp181/zap2xml

 

EDIT : Well it copies the file...  perl is moaning about dependencies when I try to run the script,  after I install them it seems to work :-

 

sudo apt-get install libcompress-raw-zlib-perl libhtml-parser-perl libhttp-cookies-perl liblwpx-paranoidagent-perl libconfig-json-perl libjson-xs-perl

  • Author

No idea...  I got it to work just fine :-

 

https://github.com/cdp181/zap2xml

 

EDIT : Well it copies the file...  perl is moaning about dependencies when I try to run the script,  after I install them it seems to work :-

 

sudo apt-get install libcompress-raw-zlib-perl libhtml-parser-perl libhttp-cookies-perl liblwpx-paranoidagent-perl libconfig-json-perl libjson-xs-perl

 

Going to try yours now Chris.  Thx!

 

Not so worried about the Perl stuff just yet.  I think that is going to take a lot of tinkering with (that cpanm stuff) to get it going.

 

John

No worries,  good luck getting it working.

  • Author

No worries,  good luck getting it working.

 

Actually I take that back!  :)  Your container works straight away.  I was just able to use the perl script to scrape guide data from my account on zap2it.com.  Awesome!

 

Only thing that is left is to build a cron job in the container to run the command twice a day.

 

Chris, thanks a million!

 

John

No worries,  good luck getting it working.

 

Actually I take that back!  :)  Your container works straight away.  I was just able to use the perl script to scrape guide data from my account on zap2it.com.  Awesome!

 

Only thing that is left is to build a cron job in the container to run the command twice a day.

 

Chris, thanks a million!

 

John

In my WG++ container there should be how to add a cron job for the nobody user somewhere. Look at my github ( user tobbenb).

i'm a bit concerned about a fist container

It's gonna be a knock out container that's for sure...

i'm a bit concerned about a fist container

It's gonna be a knock out container that's for sure...

It's going to be nice to have if you are about to fall a sleep in front of the monitor. Out comes a fist and slaps you awake  ;D

 

Only thing that is left is to build a cron job in the container to run the command twice a day.

 

John

So I had some time to check what I do in the WG++ container and here is how I solve it.

 

I have a script that runs when the container is started and in there I check if there is a file I called mycron with the cron entry for running WG++'s update script.

 

This is the part I have in the startup script:

 

if [ -e /config/mycron ]; then
  crontab -u nobody /config/mycron
fi

 

This checks if there is a file called mycron in /config and then adds it to cron as the user nobody.

 

in the mycron file I have this:

 

02 02 * * * /wg++/update.sh

 

It runs the script update.sh in the folder /wg++/ 02:02 every day (well.. night actually :) ).

 

The startup.sh is added to /etc/my_init.d/ folder and is then run on each startup. This is in a phusion baseimage.

 

So that is how  I do it. There is probably other ways to do it also.

  • Author

i'm a bit concerned about a fist container

It's gonna be a knock out container that's for sure...

It's going to be nice to have if you are about to fall a sleep in front of the monitor. Out comes a fist and slaps you awake  ;D

 

I think sparkly had a different intention for the 'fist'.  :S

  • Author

 

Only thing that is left is to build a cron job in the container to run the command twice a day.

 

John

So I had some time to check what I do in the WG++ container and here is how I solve it.

 

I have a script that runs when the container is started and in there I check if there is a file I called mycron with the cron entry for running WG++'s update script.

 

This is the part I have in the startup script:

 

if [ -e /config/mycron ]; then
  crontab -u nobody /config/mycron
fi

 

This checks if there is a file called mycron in /config and then adds it to cron as the user nobody.

 

in the mycron file I have this:

 

02 02 * * * /wg++/update.sh

 

It runs the script update.sh in the folder /wg++/ 02:02 every day (well.. night actually :) ).

 

The startup.sh is added to /etc/my_init.d/ folder and is then run on each startup. This is in a phusion baseimage.

 

So that is how  I do it. There is probably other ways to do it also.

 

Exactly what I needed.  Thx saarg!

 

I'm still locking down the guts of the container.  I should be ready to include the cron bits later today.

 

My intention is to have multiple versions (branches).  The master will work with a single .conf file (one lineup).  I will also have branches that allow for multiple lineups (separate .confs) and will merge the resulting XMLs into a single guide.xml file.  This is the one that I would use since I rely on 2 guide data from 2 different zipcodes to cover all of my channels.

 

Once I feel it is stable enough (and you have time), maybe we can merge into your tvheadend containers.

 

Stay tuned...

  • Author

I have a question...

 

Is there a trick to ADDing a file into a folder that will be mapped as a VOLUME?  This is what I have:

 

RUN mkdir /zap2xml
RUN mkdir /config
ADD /confs /config/
ADD /zap2xml /zap2xml/
RUN chmod +x /zap2xml/*

# Volume mappings
VOLUME /config /data

 

However, the contents of the /confs folder on my github is not being added to /config in the container.  When I exec into the container and look a folders, the /config folder is 99/users.  Is this causing the issue?  Or is setting the volume mapping after the ADD deleting the contents of that folder?

 

VhYXJWT.png

 

My goal is to drop a config template in the /config folder that the user can copy and adjust as necessary.

 

John

i'm a bit concerned about a fist container

It's gonna be a knock out container that's for sure...

It's going to be nice to have if you are about to fall a sleep in front of the monitor. Out comes a fist and slaps you awake  ;D

 

I think sparkly had a different intention for the 'fist'.  :S

well... That would also work I guess  :o

  • Author

I have a question...

 

Is there a trick to ADDing a file into a folder that will be mapped as a VOLUME?  This is what I have:

 

 

 

I think I figured this out.  Just add a line to the dockerfile to copy the template from /confs to /config.

I have a question...

 

Is there a trick to ADDing a file into a folder that will be mapped as a VOLUME?  This is what I have:

 

RUN mkdir /zap2xml
RUN mkdir /config
ADD /confs /config/
ADD /zap2xml /zap2xml/
RUN chmod +x /zap2xml/*

# Volume mappings
VOLUME /config /data

 

However, the contents of the /confs folder on my github is not being added to /config in the container.  When I exec into the container and look a folders, the /config folder is 99/users.  Is this causing the issue?  Or is setting the volume mapping after the ADD deleting the contents of that folder?

 

VhYXJWT.png

 

My goal is to drop a config template in the /config folder that the user can copy and adjust as necessary.

 

John

 

Add the below after Use baseimage-docker's init system CMD

 

#Change uid & gid to match Unraid
RUN usermod -u 99 nobody && \
    usermod -g 100 nobody

 

This will fix the problem with 99 instead of nobody. It has nothing to do with the problem of the files not showing up.

I have a question...

 

Is there a trick to ADDing a file into a folder that will be mapped as a VOLUME?  This is what I have:

 

 

 

I think I figured this out.  Just add a line to the dockerfile to copy the template from /confs to /config.

If I remember correctly there are some quirks when the folder you map with VOLUME have content. You could try to do the mapping before you create the folder. If that doesn't work, you can always add it to a temp folder and then copy the files to the /config after the VOLUME mapping.

 

Do you only build the containers on the docker hub or do you build them locally for testing?

I always build them locally when testing /creating containers. Much faster than waiting for the docker hub to finish the build.

  • Author

 

If I remember correctly there are some quirks when the folder you map with VOLUME have content. You could try to do the mapping before you create the folder. If that doesn't work, you can always add it to a temp folder and then copy the files to the /config after the VOLUME mapping.

 

This is essentially what i was doing.  I see sparkly does this in his kodi-headless container with the advancedsetings.xml.

 

Do you only build the containers on the docker hub or do you build them locally for testing?

I always build them locally when testing /creating containers. Much faster than waiting for the docker hub to finish the build.

 

Didn't even know this was an option.  I'll look into it.  :)

 

Do you only build the containers on the docker hub or do you build them locally for testing?

I always build them locally when testing /creating containers. Much faster than waiting for the docker hub to finish the build.

 

Didn't even know this was an option.  I'll look into it.  :)

 

The only thing you need to do is to clone your github repo locally, then ssh into the server and issue this command in the folder the Dockerfile is located:

 

docker build --tag=somename .

The tag is only lowercase and 0-9 I think, but you'll get an error if it's not accepted.

If it builds correctly you can just change the repo field in the docker template to the tag you used and your container starts :) Then you don't need to download anything from docker hub either  :D

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.