Basic Docker CLI Commands

Once you have install docker logical next step is to playaround with basic commands to ensure you get comfortable .  If you haven’t had chance then you can refer my previous post of Docker Installation (Click Here)
Full set of commands along with description can be found on
  
I thought of sharing the basic commands which could be useful for the guys who are doing it for the first time
Category
Command
Description
Output
Containers
docker run “image name”
creates and starts a container in one operation
Containers
docker run -it ubuntu /bin/bash
launch a bash shell interactively in the new Ubuntu container
Note
Notice the prompt has change from host to container
Containers
docker run -d ubuntu /bin/sh -c \”while true; do echo \’hello docker\’; sleep 10; done\”
You can run containers in the
background as daemons with the docker run -d switch
Containers
docker ps
docker ps –a
With recent release of docker we can also use
docker container ls
docker container ls –a
List Active containers.
If used –a it lists all containers
Containers
docker exec -it “containerid” “cmd”
Run a command in a running container
Containers
docker rm “Container ID ”
Remove one or more containers
Images
docker images
List images
Images
docker rmi “Image ID”
Remove one or more images
Debugging/Troubleshooting
docker log “containerid’
Fetch the logs of a container
Debugging/Troubleshooting
docker stats -a
Display a live stream of container(s) resource usage statistics
Debugging/Troubleshooting
docker top “containerid”
Display the running processes of a container
Debugging/Troubleshooting
docker inspect “containerid”
Return low-level information on Docker objects.
In my example I have searched for IP Address of the container using grep

0 thoughts on “Basic Docker CLI Commands

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: