Here are some common Docker commands that are essential for managing Docker containers, images, networks, and volumes:
Common Docker Commands
-
docker run: Creates and starts a new container from a specified image.docker run [OPTIONS] IMAGE [COMMAND] [ARG...] -
docker ps: Lists all running containers. Usedocker ps -ato see all containers, including stopped ones.docker ps -
docker stop: Stops a running container.docker stop CONTAINER_ID -
docker start: Starts a stopped container.docker start CONTAINER_ID -
docker rm: Removes one or more stopped containers.docker rm CONTAINER_ID -
docker rmi: Removes one or more images from the local storage.docker rmi IMAGE_ID -
docker images: Lists all available images on the local machine.docker images -
docker pull: Downloads an image from a Docker registry (e.g., Docker Hub).docker pull IMAGE_NAME -
docker push: Uploads an image to a Docker registry.docker push IMAGE_NAME -
docker exec: Executes a command in a running container.docker exec -it CONTAINER_ID COMMAND -
docker logs: Fetches the logs of a container.docker logs CONTAINER_ID -
docker network ls: Lists all Docker networks.docker network ls -
docker volume ls: Lists all Docker volumes.docker volume ls -
docker-compose: A command-line tool for defining and running multi-container Docker applications using adocker-compose.ymlfile.docker-compose up
Summary
These commands form the foundation of Docker usage, allowing you to create, manage, and interact with containers and images effectively. Familiarity with these commands will greatly enhance your ability to work with Docker.
If you have any specific commands you want to know more about or need further clarification, feel free to ask!
