Difference between revisions of "Docker"

From Bebot Wiki 2
Jump to navigationJump to search
 
(71 intermediate revisions by the same user not shown)
Line 1: Line 1:
===== Docker =====
+
<pre>
 +
                    ##        .       
 +
              ## ## ##      ==        
 +
          ## ## ## ##      ===        
 +
      /""""""""""""""""\___/ ===     
 +
  ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
 +
      \______ o          /           
 +
        \    \        __/           
 +
          \____\______/         
 +
</pre>
 +
===== Preamble =====
 +
 
 +
So using Docker can save you some installation hassle, especially if you're NOT a PHP/SQL expert it will save you huge time ... but beware that understanding Docker also requires some practice of its own !
 +
 
 +
 
 +
Generally, you could consider Docker is no less than amazing if you'd run only one (or very few) bot(s), same if you'd want a very quick discovery on Bebot's functions. In such case Docker is unbeatable on many aspects :
 +
 
 +
With very few actions from you, thanks to Docker's automations based on simple lightweight textfiles, you would configure then install and quickly run some sort of isolated "VMs" bringing your bot(s) and DataBase to life.
 +
 
 +
 
 +
But beyond, eg if you wanted to optimizely run multiple bots from an unique PHP-code installation with all pointing towards same Database or needing some proxy (eg Aocp), it'd possibly not be the best choice as each instance would then weight full Docker image(s)/container(s) in RAM/CPU.
 +
 
 +
For such more complicated cases we'd rather point you at the classical way explained with details within both Bebot README and http://wiki.bebot.link/index.php/Installation
 +
 
  
So using Docker can save you some installation hassle, but you'll need to have it installed properly - depending on system hosting your bot(s) :
+
Now you're aware of this all, and if you feel ready for it, let's proceed into Docker below.
 +
 
 +
 
 +
===== Install =====
 +
 
 +
Before anything else, you'll need to have Docker installed properly - depending on system hosting your bot(s) :
  
 
Windows => https://docs.docker.com/desktop/install/windows-install/
 
Windows => https://docs.docker.com/desktop/install/windows-install/
Line 9: Line 37:
 
Mac => https://docs.docker.com/desktop/install/mac-install/
 
Mac => https://docs.docker.com/desktop/install/mac-install/
  
Note : if you're NOT a PHP/SQL expert this will save you time but beware that understanding Docker also requires some practice of its own ...
+
 
 +
Also notice that we'll often refer to "console" below. This is a text command line prompt we'll often need.
 +
 
 +
For Linux/Mac it should be available into your shortcuts.
 +
 
 +
For Windows you'd have to open menu and type "cmd" or "powershell".
 +
 
 +
 
 +
Just make sure you're installed and ready to type, then continue to next section.
 +
 
 +
 
 +
===== DB prep =====
 +
 
 +
Now we have to determine how to manage our DataBase. For the SQL there are three possibilites :
 +
 
 +
SQL1: you already have an external server ; just make sure it's reachable (eg : ping its ip) from your host, and check if its facial port (usually 3306) is correctly opened.
 +
 
 +
SQL2: you opted for a local service on host ; so you'd usually go for usual SQL port (3306) but instead of 127.0.0.1 default ip we'd advice you default docker0 network ip 172.17.0.1
 +
 
 +
SQL3: you are about to run a container for that ; you can skip this part fully as we'll explain you how to set this up correctly later in "build" section, it's the simplest in fact !
 +
 
 +
 
 +
Here some command or documentation to verify elements for cases SQL1/2 :
 +
 
 +
- IP/Network on Linux/Mac (try from a console : ip a) and Windows (also in console : ipconfig)
 +
 
 +
- Ports/Services on Linux/Mac https://vitux.com/find-open-ports-on-debian and Windows https://www.geeksforgeeks.org/how-to-check-open-tcp-ip-ports-in-windows
 +
 
 +
- also find SQL config (usually .cnf) file(s) and check that your parameter "bind-address" is correct, otherwise change it and restart service
 +
 
 +
 
 +
! <span style="color:#CC9900">ATTENTION</span> ! in upper cases SQL1/2 you will have to :
 +
 
 +
- CREATE a DATABASE dedicated for the bot (you can name it as you like but remember it)
 +
 
 +
- make an USER with PASSWORD and expected source (eg : @'%' to accept external requests)
 +
 
 +
- also GRANT that USER all PRIVILEGES on the DATABASE you created upper
 +
 
 +
 
 +
If needed, you may have to read some SQL doc, as https://dev.mysql.com/doc/ and adapt it to you context.
 +
 
 +
 
 +
But for generic example it will usually look like the following :
 +
 
 +
mysql (enters prompt, optional parameters are --user --password + for distant server --host)
 +
 
 +
> CREATE DATABASE bebotdbname;
 +
 
 +
> CREATE USER 'bebotuzr'@'%' IDENTIFIED BY 'botpass';
 +
 
 +
> GRANT ALL PRIVILEGES ON bebotdbname.* TO 'bebotuzr'@'%';
 +
 
 +
 
 +
If you ain't sure, you can verify your work is fine by doing :
 +
 
 +
> SHOW DATABASES; (should show the DB you created upper among list)
 +
 
 +
> SELECT User, Host FROM mysql.user; (should show your upper user among list)
 +
 
 +
> SHOW GRANTS FOR 'bebotuzr'@'%'; (should show the upper GRANT among list)
 +
 
 +
 
 +
If all here is done (or if you're in upper case SQL3) let's move on forward.
  
  
 
===== Build =====
 
===== Build =====
  
Once the software is installed, you first have to build an image from 2 docker elements below.
+
Once the software is installed, you first have to build runnable images from Bebot Docker preset configs :
 +
 
 +
Get them from https://github.com/bitnykk/DockerBeBot/ (download/decompress the .zip or use git clone)
 +
 
 +
 
 +
Then in command line, enter (cd) into the folder corresponding to your situation. Their name have 3 parts :
  
Create a dedicated folder (let's name it "botfolder" for later reference) & go in it to create these 2 text files :
+
1: "linux" or "windows", which depends on your host Operating System,
  
 +
2: "official" to run latest stable bot, or "sandbox" for some dev/beta testing,
  
"Dockerfile" (with no extension)
+
3: "botonly" (in upper cases SQL1/2) or "botplusdb" (in upper case SQL3).
 +
 
 +
 
 +
Once inside the folder meeting your requirements, you can check (ls or dir) its content :
 +
 
 +
You get those 3 files : docker-compose.yml | docker-entrypoint.sh | Dockerfile
 +
 
 +
Note : you could edit Dockerfile and change PHP version for whatever you like ; more details on its modules/config at https://www.php.net/docs.php
 +
 
 +
In upper case SQL3, you'd also have to setup your SQL credentials within docker-compose.yml (4 values to modify under "environment" part).
 +
 
 +
 
 +
Once everything seems correct according to your needs, just do :
 +
 
 +
<pre>docker compose build </pre>
 +
 
 +
If all goes fine you should see stuff as "Building X.Ys (10/10) FINISHED" + <span style="color:#0000FF">several blue lines starting with "=>"</span>.
 +
 
 +
 
 +
When it's over you are almost ready for the most exciting part ... but we'll need few more actions first ...
 +
 
 +
 
 +
===== Bot config =====
 +
 
 +
Beware Docker works in a way that makes the bot could wipes some files at reload so we need to render some persistents.
 +
 
 +
For that reason we will extract some files within the image we built earlier, and save them at host level to protect them.
 +
 
 +
To do this, we will now run this long line on Linux from within upper chosen folder to get bindable datas :
  
 
<pre>
 
<pre>
FROM alpine:latest
+
docker run --rm --entrypoint tar bebot-image czf - Conf Custom Extras/Bank Extras/Scripts log Text > out.tar.gz && tar xzf out.tar.gz -C . && rm out.tar.gz && chown 1000:1000 * -R
ENTRYPOINT ["/sbin/tini", "-g", "--"]
 
CMD ["/BeBot/docker-entrypoint.sh"]
 
RUN apk --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community/ add \
 
    git php82-cli php82-phar php82-curl php82-sockets php82-pdo php82-pdo_mysql \
 
    php82-mbstring php82-ctype php82-bcmath php82-json php82-posix php82-simplexml \
 
    php82-dom php82-pcntl php82-zip php82-opcache php82-fileinfo php82-mysqli sudo tini
 
RUN adduser -h /BeBot -s /bin/false -D -H bebot
 
RUN git clone https://github.com/bitnykk/BeBot.git
 
COPY docker-entrypoint.sh /BeBot
 
RUN chmod +x /BeBot/docker-entrypoint.sh
 
RUN chown -R bebot:bebot /BeBot
 
RUN chown -R bebot:bebot /BeBot/.git
 
RUN sudo ln -s /usr/bin/php82 /usr/bin/php8
 
USER bebot
 
WORKDIR /BeBot
 
 
</pre>
 
</pre>
  
 +
On Windows this can't properly, so we will let Docker manage volumes for us that will soon be explorable at network location \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\
  
"docker-entrypoint.sh"
+
https://stackoverflow.com/questions/61083772/where-are-docker-volumes-located-when-running-wsl-using-docker-desktop
  
<pre>
 
#!/bin/ash
 
# shellcheck shell=dash
 
errorMessage() {
 
        echo "$*"
 
        exit 1
 
}
 
EXITCODE=255
 
git pull
 
while [ "$EXITCODE" -eq 255 ]; do
 
        trap "" TERM
 
        # shellcheck disable=SC2086
 
        /usr/bin/php8  StartBot.php "$@"
 
        EXITCODE=$?
 
        trap - TERM
 
done
 
exit $EXITCODE
 
</pre>
 
  
 +
In any case we'll get 5 new folders ("Conf" "Custom" "Extras" "log" "Text") in chosen folder - where our 3 Docker config files are also.
 +
 +
Note : in upper case SQL3 we'll also soon have a "db" folder later at the same place, once we'll have our DB container started for first time.
 +
 +
Windows only : possibly set permissive rights on those folders/files (select all, right-click > Properties > Security) so our container access them.
  
Then in command line, you'll move into that folder to send the following command :
 
  
<pre>docker build -t bebot-imagename .</pre>
+
===== Run =====
  
(you can change "imagename" for anything you like but then you'll replace it below accordingly)
+
We're now ready to run our container(s) : 1 only if we want Bebot with our usual SQL server, otherwise 2 for Bebot + SQL both as Docker containers.
  
 +
<pre>
 +
docker compose run bebot
 +
</pre>
  
If all goes fine you should see something like "Building X.Ys (10/10) FINISHED" + <span style="color:#0000FF">several blue lines starting with "=>"</span>.
+
Your bot should now load (after launching its DB if some), check its updates then show its ip within Docker network.
  
 +
As it's our first run, bot will then ask us to fill up credentials informations.
  
NOTE : if you already have a SQL server you can use it & skip to "DB prep" below. Otherwise you must also run another container for DataBase.
+
So give him account name, pass, character, server and also owner and superadmin(s) plus few more questions.
  
The principle is therefore nearly the same. First obtain the base files by doing :
+
Then you're asked for the SQL part. In upper cases SQL1/2 you should already have everything needed here.
  
<pre>docker pull mariadb:latest</pre>
+
For upper case SQL3 you db ip should but the same than bot but end in .2 (as .1 should be host and .3 the bot itself).
  
(you also can choose an X.Y version you'd want instead of "latest" like 10.4 for example, or any other)
 
  
 +
Finish the setting up, then bot will create all his DB entries, and endly come online !
  
That once done you may see your created image(s) by doing :
+
NB : expect some deep caching at very first run keeping the bot busy for a minute or two. If anything goes wrong, restart containers (see below).
  
<pre>docker image ls</pre>
 
  
 +
===== Control =====
  
===== DB prep =====
+
Now to check if your container(s) run properly, you have a set of commands :
  
Now we have to configure both our SQL (so it's opened to Bebot's requests) and Bebot (so it connects to game server & our SQL).
+
To obtain a list of created image(s) : docker image ls
  
For the SQL there are 3 possibilites :
+
To show a list of running container(s) : docker ps (can use -a parameter to also see stopped ones)
  
1: you have an external server ; make sure it's reachable (eg : ping its ip) from your current host, also check its facial port responds.
+
To see realtime stats of container(s) : docker stats (Ctrl+c to exit)
  
2: you have a localhost service on host ; so you usually will go for default ip 127.0.0.1 on usual port 3306.
+
To passively check realtime log of a container : docker logs -f container_name_or_id (Ctrl+c to exit which will NOT shutdown bot/container)
  
3: you're about to run a container for that ; be sure to check what ip/port are set when you'll "RUN" it (below)
+
To enter container thread interactively : docker attach container_name_or_id (Ctrl+p Ctrl+q to exit without shutting down)
  
 +
To execute container interactively : docker exec -it container_name_or_id sh (Ctrl+p Ctrl+q for the same result that upper)
  
! ATTENTION ! in all 3 cases you will have to :
+
To copy from a running container : docker cp container_name_or_id:/path/to/stuff.ext .
  
- CREATE a DATABASE dedicated for the bot (you can name it as you like but remember it)
+
The same towards a running container : docker cp stuff.ext container_name_or_id:/path/to/copy/to
  
- make an USER with PASSWORD and expected source (eg : @'%' to accept external requests)
 
  
- also GRANT that USER all PRIVILEGES on the DATABASE you created upper
+
If you need to stop (and then restart) some container(s) :
  
If needed, you may have to read some SQL documentation and adapt it to you context. But for generic example :
+
To stop a given container : docker stop container_name_or_id
  
mysql (to enter prompt)
+
To stop all containers together : docker stop $(docker ps -q)
  
CREATE DATABASE bebotdb;
+
To restart stopped bot : docker compose run -d bebot (-d so it stays in background)
  
CREATE USER 'bebotuzr'@'%' IDENTIFIED BY 'mypass';
 
  
GRANT ALL PRIVILEGES ON bebotdb.* TO 'bebotuzr'@'%';
+
If Bebot git code was patched, such container restart upper should quickfix to auto-update it.
  
===== Bot config =====
+
For best reliability you also can delete bot image (its container once stopped/removed) and rebuild it with --no-cache parameter added :
  
 +
- stop all (docker compose down ; docker stop containername)
  
 +
- find & delete the bot container (docker ps -a ; docker rm fullid)
  
 +
- find & delete the bot image (docker image ls ; docker image rm imagename)
  
===== Run =====
+
- rebuild the bot image (docker compose build servicename --no-cache)
  
We're now ready to run our container(s) : 1 only if we want Bebot with our usual SQL server, otherwise 2 for Bebot + SQL both as Docker containers.
+
- restart the whole network (docker compose run -d servicename)
  
  
For SQL (optional) :
+
You may setup some task(s) (crontab on Linux/Mac / Task Manager > Startup on Windows) to run some container(s) right at host startup.
  
<pre>docker run --name mariadb-containername -e MYSQL_ROOT_PASSWORD=mypass -p 33306:3306 -d mariadb --restart=always</pre>
+
Sources : https://manpages.debian.org/bullseye/cron/crontab.5.en.html / https://www.howtogeek.com/208224/how-to-add-a-program-to-startup-in-windows/
  
(you can change "containername" for anything you like but then you'll replace it below accordingly)
+
Same way you should strongly save your SQL datas frequently as Docker won't do it for you ; can use task(s) based on mysqldump for that.
  
 +
Source : https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html
  
For Bebot (mandatory) :
 
  
Windows : <pre>docker run -d --rm --name bebot-containername --memory=128M -v C:\Folder\befolder\conf:\bebot\Conf -v C:\Folder\befolder\conf\log:\bebot\log -v C:\Folder\befolder\conf\Commodities:\bebot\Commodities bebot-buildname</pre>
+
===== Maintenance =====
  
(you must replace "buildname" and "C:\Folder\befolder" accordingly to your system ; "containername" is free to choose ; all path use antislashes \)
+
Before anything, you can troubleshoot most common mistakes verifying in order :
  
Mac/Linux : <pre></pre>
+
- correct software installation (Docker ahead of any other)
  
(you must replace "buildname" and "/path/to/befolder" accordingly to your system ; "containername" is free to choose ; all path use slashes /)
+
- your various elements ip, port, state and availability
  
 +
- you credentials (check bot's Conf folder in all cases, Docker's compose for case SQL3)
  
===== Control =====
 
  
Now to control if your container(s) run properly, and to control them you have a set of commands.
+
If needed to make house cleaning (assuming you've made <span style="color:#BB0000">BACKUPS</span> of sensible datas you could lose below !) :
  
To show a list of running container(s) : <pre>docker ps</pre>
+
To stop the containers : docker compose down (possibly --volumes param added)
  
To see realtime life of the Bebot : <pre>docker logs -f <full-containername></pre> (Ctrl+c to exit)
+
To delete the recent containers : docker rm $(docker ps -a -q)
  
To enter a given container interactively : <pre>docker exec -it <full-containername></pre>
+
To clear a given image : docker image rm -f image_name
  
Once inside, you command line window becomes the bot itself ; so you can see what the bot does realtime (sent & received datas, etc).
+
To remove all unused images : docker image prune -a
  
NOTE : if it's bot's 1st run & you didn't edit Conf/ files earlier, it's time to fill all infos (account/pass, char, game server, mysql credentials, etc).
+
To trash all useless networks : docker network prune
  
If the bot is set correctly it should go online in the game and become reachable/responsive as expected.
+
For all upper cleans + cache : docker system prune -a
  
To exit the entered container : <pre>Ctrl+p Ctrl+q</pre>
 
  
To stop a given container : <pre>docker stop <full-containername></pre> (or Ctrl+c while entered in interactive mode upper)
+
Again, any of the upper could make you lose datas, so cover yourself with some previous <span style="color:#BB0000">BACKUPS</span> (or do not blame your poor computer).
  
  
 
===== Conclusion =====
 
===== Conclusion =====
  
This guide is a work in progress and will evolve as we find improvements or tricks.
+
This guide is a work in progress, kept as simple as possible, and will evolve as we find improvements or tricks.
 +
 
 +
For more details and options you can refer to Docker official documentation here https://docs.docker.com/

Latest revision as of 20:59, 11 April 2024

                    ##        .         
              ## ## ##       ==         
           ## ## ## ##      ===         
       /""""""""""""""""\___/ ===       
  ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
       \______ o          /             
         \    \        __/             
          \____\______/           
Preamble[edit]

So using Docker can save you some installation hassle, especially if you're NOT a PHP/SQL expert it will save you huge time ... but beware that understanding Docker also requires some practice of its own !


Generally, you could consider Docker is no less than amazing if you'd run only one (or very few) bot(s), same if you'd want a very quick discovery on Bebot's functions. In such case Docker is unbeatable on many aspects :

With very few actions from you, thanks to Docker's automations based on simple lightweight textfiles, you would configure then install and quickly run some sort of isolated "VMs" bringing your bot(s) and DataBase to life.


But beyond, eg if you wanted to optimizely run multiple bots from an unique PHP-code installation with all pointing towards same Database or needing some proxy (eg Aocp), it'd possibly not be the best choice as each instance would then weight full Docker image(s)/container(s) in RAM/CPU.

For such more complicated cases we'd rather point you at the classical way explained with details within both Bebot README and http://wiki.bebot.link/index.php/Installation


Now you're aware of this all, and if you feel ready for it, let's proceed into Docker below.


Install[edit]

Before anything else, you'll need to have Docker installed properly - depending on system hosting your bot(s) :

Windows => https://docs.docker.com/desktop/install/windows-install/

Linux => https://docs.docker.com/desktop/install/linux-install/

Mac => https://docs.docker.com/desktop/install/mac-install/


Also notice that we'll often refer to "console" below. This is a text command line prompt we'll often need.

For Linux/Mac it should be available into your shortcuts.

For Windows you'd have to open menu and type "cmd" or "powershell".


Just make sure you're installed and ready to type, then continue to next section.


DB prep[edit]

Now we have to determine how to manage our DataBase. For the SQL there are three possibilites :

SQL1: you already have an external server ; just make sure it's reachable (eg : ping its ip) from your host, and check if its facial port (usually 3306) is correctly opened.

SQL2: you opted for a local service on host ; so you'd usually go for usual SQL port (3306) but instead of 127.0.0.1 default ip we'd advice you default docker0 network ip 172.17.0.1

SQL3: you are about to run a container for that ; you can skip this part fully as we'll explain you how to set this up correctly later in "build" section, it's the simplest in fact !


Here some command or documentation to verify elements for cases SQL1/2 :

- IP/Network on Linux/Mac (try from a console : ip a) and Windows (also in console : ipconfig)

- Ports/Services on Linux/Mac https://vitux.com/find-open-ports-on-debian and Windows https://www.geeksforgeeks.org/how-to-check-open-tcp-ip-ports-in-windows

- also find SQL config (usually .cnf) file(s) and check that your parameter "bind-address" is correct, otherwise change it and restart service


! ATTENTION ! in upper cases SQL1/2 you will have to :

- CREATE a DATABASE dedicated for the bot (you can name it as you like but remember it)

- make an USER with PASSWORD and expected source (eg : @'%' to accept external requests)

- also GRANT that USER all PRIVILEGES on the DATABASE you created upper


If needed, you may have to read some SQL doc, as https://dev.mysql.com/doc/ and adapt it to you context.


But for generic example it will usually look like the following :

mysql (enters prompt, optional parameters are --user --password + for distant server --host)

> CREATE DATABASE bebotdbname;

> CREATE USER 'bebotuzr'@'%' IDENTIFIED BY 'botpass';

> GRANT ALL PRIVILEGES ON bebotdbname.* TO 'bebotuzr'@'%';


If you ain't sure, you can verify your work is fine by doing :

> SHOW DATABASES; (should show the DB you created upper among list)

> SELECT User, Host FROM mysql.user; (should show your upper user among list)

> SHOW GRANTS FOR 'bebotuzr'@'%'; (should show the upper GRANT among list)


If all here is done (or if you're in upper case SQL3) let's move on forward.


Build[edit]

Once the software is installed, you first have to build runnable images from Bebot Docker preset configs :

Get them from https://github.com/bitnykk/DockerBeBot/ (download/decompress the .zip or use git clone)


Then in command line, enter (cd) into the folder corresponding to your situation. Their name have 3 parts :

1: "linux" or "windows", which depends on your host Operating System,

2: "official" to run latest stable bot, or "sandbox" for some dev/beta testing,

3: "botonly" (in upper cases SQL1/2) or "botplusdb" (in upper case SQL3).


Once inside the folder meeting your requirements, you can check (ls or dir) its content :

You get those 3 files : docker-compose.yml | docker-entrypoint.sh | Dockerfile

Note : you could edit Dockerfile and change PHP version for whatever you like ; more details on its modules/config at https://www.php.net/docs.php

In upper case SQL3, you'd also have to setup your SQL credentials within docker-compose.yml (4 values to modify under "environment" part).


Once everything seems correct according to your needs, just do :

docker compose build 

If all goes fine you should see stuff as "Building X.Ys (10/10) FINISHED" + several blue lines starting with "=>".


When it's over you are almost ready for the most exciting part ... but we'll need few more actions first ...


Bot config[edit]

Beware Docker works in a way that makes the bot could wipes some files at reload so we need to render some persistents.

For that reason we will extract some files within the image we built earlier, and save them at host level to protect them.

To do this, we will now run this long line on Linux from within upper chosen folder to get bindable datas :

docker run --rm --entrypoint tar bebot-image czf - Conf Custom Extras/Bank Extras/Scripts log Text > out.tar.gz && tar xzf out.tar.gz -C . && rm out.tar.gz && chown 1000:1000 * -R

On Windows this can't properly, so we will let Docker manage volumes for us that will soon be explorable at network location \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\

https://stackoverflow.com/questions/61083772/where-are-docker-volumes-located-when-running-wsl-using-docker-desktop


In any case we'll get 5 new folders ("Conf" "Custom" "Extras" "log" "Text") in chosen folder - where our 3 Docker config files are also.

Note : in upper case SQL3 we'll also soon have a "db" folder later at the same place, once we'll have our DB container started for first time.

Windows only : possibly set permissive rights on those folders/files (select all, right-click > Properties > Security) so our container access them.


Run[edit]

We're now ready to run our container(s) : 1 only if we want Bebot with our usual SQL server, otherwise 2 for Bebot + SQL both as Docker containers.

docker compose run bebot

Your bot should now load (after launching its DB if some), check its updates then show its ip within Docker network.

As it's our first run, bot will then ask us to fill up credentials informations.

So give him account name, pass, character, server and also owner and superadmin(s) plus few more questions.

Then you're asked for the SQL part. In upper cases SQL1/2 you should already have everything needed here.

For upper case SQL3 you db ip should but the same than bot but end in .2 (as .1 should be host and .3 the bot itself).


Finish the setting up, then bot will create all his DB entries, and endly come online !

NB : expect some deep caching at very first run keeping the bot busy for a minute or two. If anything goes wrong, restart containers (see below).


Control[edit]

Now to check if your container(s) run properly, you have a set of commands :

To obtain a list of created image(s) : docker image ls

To show a list of running container(s) : docker ps (can use -a parameter to also see stopped ones)

To see realtime stats of container(s) : docker stats (Ctrl+c to exit)

To passively check realtime log of a container : docker logs -f container_name_or_id (Ctrl+c to exit which will NOT shutdown bot/container)

To enter container thread interactively : docker attach container_name_or_id (Ctrl+p Ctrl+q to exit without shutting down)

To execute container interactively : docker exec -it container_name_or_id sh (Ctrl+p Ctrl+q for the same result that upper)

To copy from a running container : docker cp container_name_or_id:/path/to/stuff.ext .

The same towards a running container : docker cp stuff.ext container_name_or_id:/path/to/copy/to


If you need to stop (and then restart) some container(s) :

To stop a given container : docker stop container_name_or_id

To stop all containers together : docker stop $(docker ps -q)

To restart stopped bot : docker compose run -d bebot (-d so it stays in background)


If Bebot git code was patched, such container restart upper should quickfix to auto-update it.

For best reliability you also can delete bot image (its container once stopped/removed) and rebuild it with --no-cache parameter added :

- stop all (docker compose down ; docker stop containername)

- find & delete the bot container (docker ps -a ; docker rm fullid)

- find & delete the bot image (docker image ls ; docker image rm imagename)

- rebuild the bot image (docker compose build servicename --no-cache)

- restart the whole network (docker compose run -d servicename)


You may setup some task(s) (crontab on Linux/Mac / Task Manager > Startup on Windows) to run some container(s) right at host startup.

Sources : https://manpages.debian.org/bullseye/cron/crontab.5.en.html / https://www.howtogeek.com/208224/how-to-add-a-program-to-startup-in-windows/

Same way you should strongly save your SQL datas frequently as Docker won't do it for you ; can use task(s) based on mysqldump for that.

Source : https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html


Maintenance[edit]

Before anything, you can troubleshoot most common mistakes verifying in order :

- correct software installation (Docker ahead of any other)

- your various elements ip, port, state and availability

- you credentials (check bot's Conf folder in all cases, Docker's compose for case SQL3)


If needed to make house cleaning (assuming you've made BACKUPS of sensible datas you could lose below !) :

To stop the containers : docker compose down (possibly --volumes param added)

To delete the recent containers : docker rm $(docker ps -a -q)

To clear a given image : docker image rm -f image_name

To remove all unused images : docker image prune -a

To trash all useless networks : docker network prune

For all upper cleans + cache : docker system prune -a


Again, any of the upper could make you lose datas, so cover yourself with some previous BACKUPS (or do not blame your poor computer).


Conclusion[edit]

This guide is a work in progress, kept as simple as possible, and will evolve as we find improvements or tricks.

For more details and options you can refer to Docker official documentation here https://docs.docker.com/