Skip to main content

Docker - Basic Commands


Following are frequently used Docker commands.

  1. Check the docker version.
    docker -version

  2. Pull image from docker repository.
    docker pull <image_name:tag>
    docker pull nginx

  3. List local images.
    docker images

  4. Create a container from docker image.
    docker run
    docker run -it -d nginx
    docker run --name my-nginx -it -d nginx

  5. List running containers.
    docker ps
    docker ps -a

  6. Access the running container.
    docker exec
    docker exec -it ubuntu bash

  7. Stop running container.
    docker stop 

  8. Kill running container.
    docker kill 

  9. Delete a container.
    docker rm <container_id>

  10. Delete an image from local storage.
    docker rmi <image_id>

  11. Build a docker image from a given Docker file.
    docker build .