test

Constatic

Discord Bot BaseHosting

Docker

How to host discord bot project using docker

Docker is an open-source platform that simplifies the creation, testing, and deployment of applications in containers, which are isolated and lightweight environments containing everything needed to run an application, ensuring consistency and portability across different development and production environments.

You must have Docker installed and basic knowledge of Docker. to follow this guide!

Create a Dockerfile in the project root with the following contents:

Dockerfile
FROM docker.io/library/node:21.5
 
WORKDIR /bot
 
COPY ./package*.json .
RUN npm install
 
COPY . .
 
RUN npm run build
 
CMD [ "npm", "start" ]

Create a .dockerignore file in the project root with the following contents:

.dockerignore
build
node_modules

Then run the command below:

docker build --pull --rm -f Dockerfile -t discord-bot .

The -t flag set a name for the image, in this case it will be discord-bot

After that, just run a container with this image.

docker run -d --name my-bot discord-bot

The --name flag set a name for the container, in this case it will be my-bot

That's enough, your application will be online in moments.


On this page

No Headings