Cheatography
https://cheatography.com
docker cheat sheet for learning
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Basic Docker Commands
docker ps |
List of live containers |
docker ps -a |
List all containers |
docker info |
Retrieves docker configuration |
docker version |
Retrieves docker versioning |
docker build -t <Image>:<Tag> . |
Builds a docker Image from Dockerfile or container |
docker push <Image_Name>:<Tag> |
Pushes the image to the repo |
docker pull <Image_Name>:<Tag> |
Pulls the image from the repo |
Container Commands
docker inspect <Container> |
Inspect a container |
docker stats <Container> |
Live data stream from container |
docker logs <Container> |
Retrieves the containers logs |
docker run <Container> |
Run container |
docker kill <Container> |
Kill a running container |
docker start <Container> |
Start container |
docker stop <Container> |
Stop a running container |
docker restart <Container> |
Restarts the container |
docker rm <Container> |
Remove container |
docker port <Container> |
Lists the port mapping of the container |
docker pause <Container> |
Suspends all the processes in the container |
docker unpause <Container> |
Un-suspends all the processes in the container |
<Container> can be replaced with the containers ID or NAME |
Options Keywords
-p, –-publish |
Host to container port mapping |
--publish-all |
Publish all ports |
--expose |
Expose container port |
-d, –-detach |
Run in background |
-e, –-env |
set env vars |
-v, --volume |
Mount files or directories |
-i, --interactive |
attach stdin |
-t, --tty |
pseudo-teletype |
exec |
Run a new command in a container |
cp |
copy path |
These options keywords can be add to most docker commands |
|
|
Volume Commands
docker volume ls |
List volumes |
docker volume inspect <Volume> |
Inspect volume |
docker volume create <Volume> |
Create volume |
docker volume rm <Volume> |
Removes a volume |
<Volume> can be replaced with the volume ID or NAME |
Image commands
docker images |
List images |
docker run <Image> |
runs the image |
docker create <Image>:<Tag> |
Create image |
docker rmi <Image> |
Remove image |
docker save <Image> |
Saves images to a tar archive |
Network Commands
docker network ls |
List networks |
docker network inspect <Network> |
Inspect a network |
docker network create <Network> |
Create a network |
docker network rm <Network> |
Removes a network |
docker network connect <Network> <Container> |
Connect a container to the network |
docker network connect --ip <IP> <Network> <Container> |
Specify the ip address of container interface |
docker network disconnect <Network_Name> <Container> |
Disconnect container from network |
<Network> can be replaced with the network ID or NAME |
Misc. Commands
docker cp <Container>:<source_path> <dest_path> |
Copy from container to host |
docker cp <source_path> <Container>:<dest_path> |
Copy from host to container |
docker exec -ti <Container> <Entrypoint> |
Executes the terminal of a live container |
|