I have a shell script that I use to export Env variables. This script calls a python script to get certain values from a web service that I need to store before running my primary python script.
I've tried using a RUN . /bot/env/setenv.sh
, but this doesn't seem to make the env variables available in the final container. I've tried putting the contents in an entrypoint.sh
file that ends in calling python jbot.py
, but the container never completes its setup (I assume because the script inside the entrypoint is a continuous loop?)
My entrypoint.sh
looks like this:
#!/bin/bash
. /jirabot/env/setenv.sh
python jbot.py
And the setenv.sh
is just:
#!/bin/bash
export SLACK_BOT_TOKEN="xoxb-token"
export BOT_ID=`python env/print_bot_id.py ${SLACK_BOT_TOKEN}`
My full Dockerfile is:
FROM python:2
COPY jirabot/ /jirabot/
RUN pip install slackclient schedule jira
WORKDIR /jirabot
#CMD [ "python", "jbot.py" ]
ENTRYPOINT [ "/jirabot/entrypoint.sh" ]
When I do docker run bot
, I can verify that the application is running (the bot responds to my requests appropriately). However, all of the print()
statements within jbot.py
are absent from the output -- so I have two primary questions:
Why does my entrypoint.sh
just hang the container from returning? I do docker run bot
, and I'm never returned control of the terminal. However, the bot seems to startup fine.
Why do I not get any of my print statements from jbot.py
when I open a second terminal and do docker logs <container>
?
fwiw, my jbot.py
is a while True:
loop, monitoring for input.
docker run -d bot
python -u jbot.py
For your first question, you should check the documentation of docker run
. Shortly, you are attaching with container so you will never return to your terminal. In order to detach, you need to add option -d
.
The common used command to launch a container is docker run -idt <container>
.
For your second question, the information is not enough to identify the problem, sorry. Maybe you can try again after you launching a container properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With