Loading

Quipoin Menu

Learn • Practice • Grow

docker / Basic Docker Commands
tutorial

Basic Docker Commands

As you start using Docker, you'll frequently need to manage images and containers. Here are the essential commands you should know.

Working with Images

  • List images: docker images (or docker image ls)
  • Pull an image: docker pull ubuntu (downloads the latest Ubuntu image)
  • Remove an image: docker rmi ubuntu (or docker image rm ubuntu)

Working with Containers

  • Run a container: docker run nginx (starts an Nginx container)
  • List running containers: docker ps
  • List all containers: docker ps -a
  • Stop a container: docker stop container_id_or_name
  • Start a stopped container: docker start container_id
  • Remove a stopped container: docker rm container_id
  • Remove a running container forcefully: docker rm -f container_id

Useful Options for docker run

  • -d – run in background (detached)
  • -it – interactive mode with terminal
  • --name – give the container a custom name
  • -p – publish a port (e.g., -p 8080:80)
  • -v – mount a volume
Example:
docker run -d --name mynginx -p 8080:80 nginx
This runs Nginx in the background, names it mynginx, and maps port 8080 on your host to port 80 in the container.

Clean Up Unused Resources

To free up disk space, you can remove unused containers, images, and networks:
docker system prune
Add -a to also remove unused images.


Two Minute Drill
  • List images: docker images; remove: docker rmi.
  • List containers: docker ps (running), docker ps -a (all).
  • Stop: docker stop; remove: docker rm.
  • Run in background: docker run -d.
  • Clean up with docker system prune.

Need more clarification?

Drop us an email at career@quipoinfotech.com