How can I access Docker set Environment Variables From a Cron Job

后端 未结 8 1668
野性不改
野性不改 2021-01-30 20:24

I\'ve recently tried running a cron job from within a linked docker container and run into an issue. My main docker container is linked to a postgres container and its port numb

8条回答
  •  梦毁少年i
    2021-01-30 20:49

    inspired by @Kannan Kumarasamy answer:

      for variable_value in $(cat /proc/1/environ | sed 's/\x00/\n/g'); do
        export $variable_value
      done
    

    I can't state for sure, what process with pid1 is and that its stable during lifetime of OS. but as it is the first process to be run, inside a container i guess we can take it for granted it is a process with desired env vars set. take all of this with pich of salt unless some linux/docker docs proves this is completely ok.

提交回复
热议问题