version check
docker version
Create a container — setup File System Snapshot to be used
docker create <image-name>
Start a container — Executes startup command
-a - will show you all the logs/info coming out of the container
docker start -a <container-ID>
run a docker container from image — Create + Start
docker run <image-name>
Default command override
docker run <image-name> <override-command>
Eg: "docker run busybox ls”
Eg: "docker run busybox ls”
List all running containers
docker ps
List all containers ever created
docker ps --all
Remove stopped containers
— have to redownload images
docker system prune
Logs from container
docker logs <container-ID>
Stop a container
— A hardware signal “SIGTERM" is sent to process, this gives time for program to clean-up and shut down
— If container doesn’t stop in 10 secs after issuing SIGTERM, then docker will issue a kill command
— If container doesn’t stop in 10 secs after issuing SIGTERM, then docker will issue a kill command
docker stop <container-ID>
Kill a container
— A hardware signal “SIGKILL" is sent to process, shutdowns immediately without proceeding any further
docker kill <container-ID>
Execute additional commands inside containers
-it — allows to provide input to the container
docker exec -it <container-ID> <command>
Eg: SSH into container
docker exec -it <container-ID> sh
Remove container
— Container can only be removed, if it's not running
docker container rm <container-ID>
docker container rm <container-ID>
Remove image
— To delete an image, it shouldn't be associated with any container
docker image rm <image-name>
List all images
docker images
Happy Coding 👨💻
Comments
Post a Comment