Troubleshooting Web Applications Deployed with CapRover in Docker Containers
Jump into the terminal of a CapRover app named testapp. Use Ctrl + P, then Ctrl + Q to exit that terminal without killing the container.
docker exec -it $(docker ps --filter name=srv-captain--testapp -q) /bin/sh
Logs of the deployed application (–follow keeps retrieving the latest events):
docker service logs srv-captain--my-app --since 60m --follow
CapRover logs:
docker service logs captain-captain --since 60m --follow
Logs for Docker itself (if your application keeps getting respawned in new containers, the answer may be in here):
systemctl status -l docker
See nginx records:
docker service ps captain-nginx --no-trunc
Restart CapRover:
docker service update captain-captain --force
docker service scale captain-captain=0 docker service scale captain-captain=1
Restart Docker
sudo systemctl daemon-reload sudo systemctl restart docker
If your app is running in local but the container is repeatedly crashing on the server, it may be because of a missing dependency only used by the server. For example, if you are testing in local with flask run
while the server uses gunicorn, your requirements.txt
may be missing some dependencies, as my requirements.txt
was missing the following once. I ended up installing these in the local virtual environment as a workaround, just so they are included in each new copy of the requirements.txt
after a new pip freeze
.
gevent==22.10.1 greenlet==1.1.3.post0 gunicorn==20.1.0
If you are testing locally on a Windows machine, try running the Dockerized version on WSL. The logs on the WSL terminal can contain more information.
docker build -t triggers . && docker run -it triggers
Edit the CapRover nginx config to limit dashboard access to whitelisted IPs:
docker exec -it $(docker ps --filter name=captain-nginx -q) /bin/sh apt update apt install nano -y nano /etc/nginx/conf.d/captain-root.conf
# Captain dashboard at captain.captainroot.domain.com # ... server { # ... # Add this under the line of server_name captain.***.com; # Allow only 169.55.161.198 and deny all others allow 169.55.161.198; deny all;