Docker commands are used to manage Docker containers and images. Some of the most common commands include docker run
, docker ps
, docker stop
, docker start
, docker rm
, docker images
, docker pull
, and docker push
.
Here's a breakdown of some essential Docker commands:
Container Management:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
: Creates and starts a new container from an image.docker ps
: Lists running containers.docker ps -a
: Lists all containers (running and stopped).
docker stop [CONTAINER...]
: Stops one or more running containers.docker start [CONTAINER...]
: Starts one or more stopped containers.docker restart [CONTAINER...]
: Restarts one or more running containers.docker kill [CONTAINER...]
: Kills one or more running containers (sends SIGKILL).docker rm [CONTAINER...]
: Removes one or more stopped containers.docker exec -it [CONTAINER] [COMMAND]
: Executes a command in a running container.docker logs [OPTIONS] CONTAINER
: Fetches the logs of a container.docker inspect [CONTAINER...]
: Displays detailed information about one or more containers.docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
: Copies files/folders between a container and the local filesystem.
Image Management:
docker images
: Lists all images on the host.docker pull IMAGE[:TAG]
: Downloads an image from a registry.docker push IMAGE[:TAG]
: Uploads an image to a registry.docker rmi IMAGE [IMAGE...]
: Removes one or more images.docker build [OPTIONS] PATH
: Builds an image from a Dockerfile.
Other Useful Commands:
docker version
: Displays the Docker version information.docker info
: Displays system-wide information.docker search TERM
: Searches Docker Hub for images.docker network ls
: Lists all networks.docker volume ls
: Lists all volumes.docker system prune
: Removes stopped containers, dangling images, and unused networks and volumes.docker compose up
: Builds, creates, starts, and attaches to containers for a project.docker compose down
: Stops and removes containers, networks, and volumes.
No comments:
Post a Comment