docker ps // Show running docker containers
docker ps -a // Show all containers, both stopped and running
docker ps -n x // Shows the last x containers, running or stopped, ex: docker ps -n 5)
docker ps -l
docker images
docker rm container_id
docker rm $(docker ps -a -q) // delete all containers
docker rmi <image_id> // delete an image
docker rmi $(docker images -q) // delete all images
docker start <container_id> // (ex: docker start aa3f365f0f4e)
docker start <container_name> // (ex: docker start rails_dev_container)
docker attach <container_id> // (ex: docker attach aa3f365f0f4e)
docker attach <container_name> // (ex: docker attach rails_dev_container)
docker logs container_name //
docker logs -f container_name // (like the tail -f)
docker logs -ft container_name // (prefix log entries with timestamps)
docker logs --tail 10 daemon_container (get the last 10 lines of the log)
docker logs --tail 0 -f daemon_container (follow the logs without having to read the whole log file)
docker top daemon_container
Background
docker exec -d daemon_container touch /etc/new_config_file
Interactive
docker exec -t -i daemon_container /bin/bash