June 2, 20197 yr Hi, as i started to create a own docker may some basic questions as i didnt came further yet ... sample, if i want to use a variable in the run command wich i then can configure, how would that look like in the dockerfile sample from Dockerfile # port command CMD ["-port=34400"] now i tried with entries like ENV webport CMD ["-port=$webport"] or ARG ... i guess its pretty basic but after reading several things i really dont get a clue ... next step would be to add stuff like if, then ... but first it would be nice for this basic help thanks ahead
June 2, 20197 yr 21 minutes ago, alturismo said: Hi, as i started to create a own docker may some basic questions as i didnt came further yet ... sample, if i want to use a variable in the run command wich i then can configure, how would that look like in the dockerfile sample from Dockerfile # port command CMD ["-port=34400"] now i tried with entries like ENV webport CMD ["-port=$webport"] or ARG ... i guess its pretty basic but after reading several things i really dont get a clue ... next step would be to add stuff like if, then ... but first it would be nice for this basic help thanks ahead You shouldn't set variables in the Dockerfile itself as a general rule, variables come into play at the runtime stage not the build stage. Might be helpful if you linked a Github repo or something, 'cos I'm not entirely clear what you're trying to do.
June 2, 20197 yr Author 23 minutes ago, CHBMB said: You shouldn't set variables in the Dockerfile itself as a general rule, variables come into play at the runtime stage not the build stage. Might be helpful if you linked a Github repo or something, 'cos I'm not entirely clear what you're trying to do. sure pretty simple, i try learning a little about building docker sample https://github.com/alturismo/xTeveTest/blob/master/Dockerfile <- working nuttom command port 34400 as you see i run the app and the port in docker hardcoded, now i d like to make the port configurable through the webgui, so my start was to make it variable so i could set something in unraid gui ... sample as mentioned, 1st docker, 1st tests ... i tried some stiff with ENV and ARG but never came to an result
June 2, 20197 yr OK, you're getting confused between what you do in docker versus what you do in the Unraid webgui. You add a port not a variable when you want to add a port to a Unraid template. Set the container port to whatever the container port is, then change the host port to whatever you want it to be.
June 3, 20197 yr Author g morning, well, this was just an sample with a port in this case this docker runs in host mode so port setting is obsolete next step would be to config a subdirectory etc ... thats why i would like to know if i can set a variable to the CMD argue, or is this always hardcoded ? cause when i add dockers from apps here i also often can add variables etc wich are then used on docker run
June 3, 20197 yr 16 hours ago, alturismo said: g morning, well, this was just an sample with a port in this case this docker runs in host mode so port setting is obsolete next step would be to config a subdirectory etc ... thats why i would like to know if i can set a variable to the CMD argue, or is this always hardcoded ? cause when i add dockers from apps here i also often can add variables etc wich are then used on docker run You're probably better looking at examples of how it's done. Dockerfile = uncustomised build that will be the same for everyone. Init stage = Where customisation happens, copying/linking stuff to persistent storage, ingesting environmental variables to change the way the container runs or functions.
June 4, 20197 yr Author thanks for the reply, i thought thats the init stage (variables to the app run command) i tried to figure it by taking a look at some dockers around, but actually didnt come further, nvm, i ll take another attempt some day thanks again
June 10, 20197 yr Author may another question with a different approach i tried now an startup script (entrypoint.sh) to get my execution(s) customizable my goal is a config file wich then is used for executions my problem seems to be the loop and detaching the app from terminal so it ll kill the app after the loop is done, while if theres no config file its working ... thanks ahead for an tip sample config.txt -port="34400" -debug="0" -config="/root/.xteve/test/" -port="34401" -debug="2" entrypoint.sh #!/bin/sh if [ -f "/root/.xteve/custom.txt" ]; then echo "Custom config found" file="/root/.xteve/custom.txt" while read -r line do if ! [[ ${line:0:1} = \# ]] ; then echo "Starting xteve with "$line"" ./xteve/xteve "$line" ### << NOT working, gets executedm then stops ... docker dead fi done <"$file" echo "all custom started" else echo "no custom config, starting default" ./xteve/xteve -port="34400" -debug="0" ### << working fi Edited June 10, 20197 yr by alturismo
Archived
This topic is now archived and is closed to further replies.