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

后端 未结 8 1665
野性不改
野性不改 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条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 20:33

    You should export your environment variable before you run cronjobs.

    Other solutions are fine but they will fail when there are any special characters in your environment variable.

    I have found the solution:

    eval $(printenv | awk -F= '{print "export " "\""$1"\"""=""\""$2"\"" }' >> /etc/profile)

提交回复
热议问题