Docker CheatSheet
Compilation of some of the most useful commands that I usually need for docker, that I keep on having to search google for.
- List of Containers Running
- List All Containers
- Open Bash on a Container
- Copy files to Container
- Copy files from Container
- View Logs of Container
List of Containers Running
docker ps
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a65b4a162136 webserver:latest /bin/bash ... ... 22/tcp, 80/tcp webserver
List all Containers
docker ps -a
Open Bash on a Container
sudo docker exec -i -t a65b4a162136 /bin/bash
or
sudo docker exec -i -t webserver /bin/bash
Copy files to Container
docker cp application.war webserver:/root/application.war
Copy files from Container
docker cp webserver:/root/application.war application.war
View Logs of Container
docker logs a65b4a162136