docker build -t fastapi .Usage: Builds a Docker image named fastapi from the Dockerfile in the current directory. The -t flag tags the image with the specified name.
docker system prune -aUsage: Removes all unused containers, networks, images, and optionally volumes. The -a flag removes all dangling and unused images. Use with caution as it frees up disk space.
docker ps -aUsage: Lists all containers (running and stopped). Without -a, only running containers are shown.
docker run --rm -it -p 8000:8000 fastapi bashUsage:
--rm: Automatically removes the container when it exits-it: Interactive terminal (combines-ifor stdin and-tfor terminal)-p 8000:8000: Maps port 8000 from container to host- Starts a bash shell inside the
fastapicontainer for debugging
docker rmi fastapiUsage: Removes the Docker image named fastapi. Make sure no containers are using this image before deletion.
build -t fastapi .Usage: Shorthand for building the image (note: typically requires docker prefix).
docker imagesUsage: Displays all Docker images on your system with their repository, tag, image ID, creation time, and size.
docker rmi $(docker images -q) -fUsage:
docker images -q: Lists all image IDsdocker rmi: Removes images-f: Force remove even if images are in use- Combined: Removes all Docker images forcefully. Use with caution.
docker compose upUsage: Starts and runs all services defined in docker-compose.yml. Containers run in the foreground. Press Ctrl+C to stop.
docker compose up --buildUsage: Rebuilds Docker images before starting services. Useful when you've made changes to the Dockerfile or code. Ensures services run with the latest builds.