Docker

From My Mnemonic Rhyme
Revision as of 13:59, 24 January 2024 by Weiss (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Some useful commands

see: https://docs.docker.com/engine/reference/commandline/compose/

diagnose

sudo docker ps                                                         # show active containers
sudo docker ps -a                                              # show all containers
sudo docker top CONTAINER -eo pid,cmd          # show running processes for container
sudo docker exec -it CONTAINER bash -l         # start shell in container
sudo docker-compose restart CONTAINER          # restart container

view logs

 
sudo docker logs CONTAINER                                     # show logs for container
sudo docker logs CONTAINER -f                          # show logs for container (continous updating)
sudo docker-compose logs --tail=0 -f           # show logs for ALL containers (continous updating)

get new image and restart

sudo docker-compose pull                                       # download (new) images from registry
sudo docker-compose up -d CONTAINER            # recreate and restart container (e.g. to activate new image)
# OR (if you know nothing critical is going on)
sudo docker-compose up -d                                      # recreate and restart ALL containers (e.g. to activate new image)

delete and recreate container

 sudo docker-compose stop CONAINER
 sudo docker-compose rm CONAINER
 sudo docker-compose up -d CONAINER