Docker CheatSheet

By | 22/12/2019
$ docker ps    # List all running containers
$ docker ps --all    # List all containers whether running or not
$ docker system prune    # remove all containers

To run container and see output add -a flag

$ docker logs <container id>    # Show logs from last time container ran
$ docker stop <container id>    # Sends shutdown (sig term) within 10 seconds
$ docker kill <container id>     # Kill container (sig kill) shut down now

Run Redis container and connect through redis cli

$ docker run redis
Start new terminal and run:
$ docker exec -it <container id> <command>

-i attaches anything we type attached to stdin
-t attaches output from stdout and shows on screen