Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nithin69/0debfe230394f47e2c35042fa4cb6d73 to your computer and use it in GitHub Desktop.
Save nithin69/0debfe230394f47e2c35042fa4cb6d73 to your computer and use it in GitHub Desktop.
docker commands and their usages
docker run – Runs a command in a new container.
docker start – Starts one or more stopped containers
docker stop – Stops one or more running containers
docker build – Builds an image form a Docker file
docker pull – Pulls an image or a repository from a registry
docker push – Pushes an image or a repository to a registry
docker export – Exports a container’s filesystem as a tar archive
docker exec – Runs a command in a run-time container (Usage: docker exec -it <container id> bash/shell)
docker search – Searches the Docker Hub for images
docker attach – Attaches to a running container
docker commit – Creates a new image from a container’s changes
docker –version - to know docker version
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 kill -> 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
(Usage: docker kill <container id>)
docker login -> This command is used to login to the docker hub repository
docker push -> (Usage: docker push <username/image name>) This command is used to push an image to the docker hub repository
docker images -> This command lists all the locally stored docker images
docker rm -> (Usage: docker rm <container id>) This command is used to delete a stopped container
docker rmi -> (Usage: docker rmi <image-id>) This command is used to delete an image from local storage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment