Sunday 2 February 2020

Docker Commands

Docker useful commands -   


  • docker –version
  • docker pull <image name>
  • docker run -it -d <image name>  -- This command is used to create a container from an image
  • docker ps  -- This command is used to list the running containers.
  • docker ps -a -- This command is used to show all the running and exited containers
  • docker exec -it <container id> bash  -- This command is used to access the running container
  • docker stop <container id> -  This command stops a running container
  • docker kill <container id> - This command kills the container by stopping its execution immediately. The difference between ‘docker kill’ and ‘docker stop’ is that ‘docker stop’ gives the container time to shutdown gracefully, in situations when it is taking too much time for getting the container to stop, one can opt to kill it
  • docker commit <conatainer id> <username/imagename>  -- This command creates a new image of an edited container on the local system
  • docker login  -- This command is used to login to the docker hub repositors
  • sync && sysctl -w vm.drop_caches=3   -- clear the cache memory on unbutu
  • docker logs --tail 300  containerID
  • docker logs --since 10 containerID  (10 Minutes)
  • docker inspect --format={{.LogPath}} containerID
  • tail -f `docker inspect --format={{.LogPath}} containerID`
  • grep error `docker inspect --format={{.LogPath}} containerID`