I've noticed that currently only CoolQ robot supports running on Docker in Linux.
So, I'm going to install the CoolQ robot. It doesn't consume a lot of resources, probably about 180MB of memory.
The CoolQ official website provides the dockerCOOLQ Docker 2.0.
However, I prefer to use the one with the HTTP plugin for some functionality development. I chose the one made by a senior, which contains the HTTP plugin CQHTTP Docker.
First, pull the image. I found the download speed to be a bit slow, so I ran it in a screen session to download slowly.
docker pull richardchien/cqhttp:latest
After the download is complete, start the container for testing.
docker run -ti --rm --name coolq \
-v /home/coolq:/home/user/coolq \ # Mount the host directory to the container for persistent storage of the CoolQ program files
-p 9000:9000 \ # noVNC port for controlling CoolQ from the browser
-p 5700:5700 \ # Port opened by the HTTP API plugin
-e COOLQ_ACCOUNT=123456 \ # Optional but recommended: the QQ account to log in
-e CQHTTP_POST_URL=http://example.com:8080 \ # Event reporting address
-e VNC_PASSWD=111111111 \ # noVNC password
-e CQHTTP_SERVE_DATA_FILES=yes \ # Allow access to CoolQ data files through the HTTP interface
richardchien/cqhttp:latest
At this point, you can log in to noVNC to view and log in.
If the test is successful, change --rm to -d in the start parameters for persistent running.
Since I have a scheduled task to turn the computer on and off at regular intervals, and CoolQ doesn't start automatically, I chose supervisord to auto-start it.
Note autorestart=false, because after starting coolq, it will exit(0), causing supervisord to constantly attempt to restart. We only need it to start once.
Note that the reporting address cannot be 127.0.0.1 because the container has its own 127.0.0.1. In general, you can use the machine's ip address as the reporting address.
Due to Docker directly modifying iptables and having higher priority than ufw, the opening and closing of its listening ports cannot be controlled through ufw, and Docker information needs to be manually configured.
# vim /etc/default/ufwDEFAULT_FORWARD_POLICY="ACCEPT"
# vim /etc/ufw/before.rules# Add the following content before *filter# 172.17.0.0/16 is the docker bridge address, may vary*nat
:POSTROUTING ACCEPT [0:0]-A POSTROUTING ! -o docker0 -s 172.17.0.0/16 -j MASQUERADE
COMMIT
# vim /etc/default/docker# Add this configuration informationDOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 --iptables=false"
# vim /etc/docker/daemon.json# Create this file if it doesn't exist{"iptables":false}