I'm fairly new to Docker and am trying to have a python Discord bot in a container.
My project folder structure is the following:
- util
- - logger.py
- cogs
- - part-of-the-bot.py
- requirements.txt
- run.py
I've checked some tutorials and the official python docker hub page to help me create the Dockerfile
:
FROM python:3.9
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN chmod +x run.py
CMD [ "python", "run.py" ]
After that, I use docker build -t bot .
and docker-compose with the following YAML file:
version: '3'
services:
discord-bot:
image: bot:latest
restart: unless-stopped
volumes:
- ~/volumes/bot:/usr/src/app
However, there are some issues with it:
Currently I get an error about the file /usr/src/app/run.py
not existing:
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
python: can't open file '/usr/src/app/run.py': [Errno 2] No such file or directory
I have checked this with some RUN pwd
and RUN ls
in the Dockerfile and everything seems to have been copied correctly.
I'm also having trouble figuring out if I need to open a port for the Discord bot to work.
EDIT: I had tried the discord.py
image on docker hub but it seems it is not suited for the Raspberry Pi architecture.