Docker is a service that helps in creating isolation in the local environment. For example, if your machine runs on Windows with Python 2, you won't have to worry about running the bot that has been developed on Linux with Python 3.7 or 3.8.
The introduced Dockerfile
uses Ubuntu 18.04
and Python3.8
to run the bot in an isolated environment.
foo@bar:~$ git clone https://github.com/cheran-senthil/TLE
- Navigate to
TLE
and Build the image using the following command:
foo@bar:~$ sudo docker build .
- Create a new file
environment
fromenvironment.template
.
cp environment.template environment
Fill in appropriate variables in new "environment" file.
- open the file
environment
.
export BOT_TOKEN="XXXXXXXXXXXXXXXXXXXXXXXX.XXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXX"
export LOGGING_COG_CHANNEL_ID="XXXXXXXXXXXXXXXXXX"
-
Change the value of
BOT_TOKEN
with the token of the bot you created from this step. -
Replace the value of
LOGGING_COG_CHANNEL_ID
with discord channel id that you want to use as a logging channel.
- Get the id of the image you just built from
sudo docker images
and run:
foo@bar:~$ sudo docker run -v ${PWD}:/TLE -it --net host <image_id>
PS: use -d
flag to run in backgroud. Then to kill backgroud container, Get the id of the container using sudo docker ps
and run sudo docker kill <container_id>
To Run Commands inside the container
- Get the id of the container you just run using
sudo docker ps
and run:
foo@bar:~$ sudo docker exec -it <container_id> bash