Docker daily usage commands list for Devops team
Check the images and repository in Docker
# List all available local images
docker images
# Search for docker images
docker search <image>
# Build an image with a dockerfile
docker build -t <image>:<tag> <run_directory>
# Login to a remote repository
docker login <repository>
#push an image to your remote repository
docker push <image>:<tag>
# remove a local docker image
docker rmi <image>:<tag>
#show metadata for an image or detail
docker inspect <image>
#Remove all unused docker images
docker image prune
Process management commands for docker:
#show all running docker containers
docker ps
#show all docker containers
docker ps -a
# run a container
docker run -it <image>:<tag>
#run a container in background
docker run -d <image>:<tag>
#Kill a container
docker kill <container>
Manage volumes & ports in Docker
#list volumes
docker volume ls
#create a volume
docker volume rm <volume>
#Delete a volume
docker volume rm <volume>
#show volume metadata
docker volume inspect <volume>
#delete all volumes not attached to a container
docker volume prune
#mount a local directory to your container
docker run -v <localdir>:<container_dir> <local_dirs>
#copy file or folder from a docker container to host machine
docker cp <container>:<container_dir> <local_dir>
#map a local port to a docker instance:
docker run -d -p 127.0.0.1:<local_port>:<docker_port> <image>
# list the ports a docker container is running on
docker port <container>
Docker troubleshooting commands for container running:
# show the logs of a container
docker logs <container>
# Tail logs of a container
docker logs -f <container>
#show timestamps on docker logs
docker logs -t <container>
#show details of a container
docker inspect <container>
#show a top view of process running on a container
docker top <container>
#Show stats view for all docker containers
docker stats
#connect to already running container
docker attach <container>
#Execute a command on a container
docker exec -it <container_id> /bin/bash
#show docker system wide information
docker system info
#show docker disk space used
docker system df
Like this:
Like Loading...