I am trying to build a docker to host my Discord bot. The dockerfile is
FROM python:3.8
COPY ./Elevate/* /docker/
RUN python3.8 -m pip install discord.py==1.5.1
RUN python3.8 -m pip install -r docker/requirements.txt
CMD ["python", "/docker/bot.py"]
and docker-build . -t bot
works fine. However, when I try to run the docker, I get
File "/docker/bot.py", line 2, in <module>
import discord
ModuleNotFoundError: No module named 'discord'
When building the docker, I can see that it successfully installed discord==1.5.1
requirements.txt contains:
discord.py == 1.5.1
dblpy
python-dateutil
babel
aiohttp-requests
parsedatetime
wavelink
pillow
statcord.py
jishaku
ksoftapi
I'm pretty new to docker, so if this is a stupid mistake, please don't judge :)
Change the requirements.txt from
to
It's a best practice to maintain a
requirements.lock
. You can generate the lock file by runningpip freeze > requirements.lock
in the docker container.Sample Command:
docker exec -it <image> pip freeze > requirements.lock