Closed dfyzicka closed 1 year ago
Hi, the docker container expects a config.py file which contains e.g. the bot token etc. Check this for an example config file.
As can be seen in the docker-compose.yml you need to pass the config.py as a docker volume to the container.
I renamed config.sample.py to config.py and added the bot token. When I usepython3 bot.py
, the code runs without errors. However, when I build the container (docker build -t blackjack .
), it builds without errors. But when I try to run it using docker run blackjack
or docker compose up
, it complains about the config. And I reviewed the Dockerfile
and docker-compose.yml
files, which indicate that the config.py
file should be copied into the working directory.
The config.py is never included into the container since it contains secrets (such as the bot token). I explicitly excluded it via the .dockerignore file
Instead you should mount the file via a docker volume.
docker run -v ./config.py:/blackjackbot/config.py blackjack
Thank you very much, I'm just a Docker enthusiast and didn't quite understand it at first, thank you again.
Hello, could you please advise me on what I might be doing wrong. When running the bot using Python - the bot works perfectly fine, but when I build the container, it fails to launch and returns an error:
Traceback (most recent call last): File "/blackjackbot/bot.py", line 9, in
import config
ModuleNotFoundError: No module named 'config'