Back to Tech Corner
DevOps

Install Docker Command

# install docker
yum install docker -y
# to see all images present
docker images
# find an image in docker-hub
docker search <image name>
# download image
docker pull <image-name>
# name & create container if no name default name is used
docker run -it --name [container name] [os type]
docker run -it --name rafi ubuntu /bin/bash

-i = interactive
-t = terminal
# check service status
service docker status
# start container
docker start [container-name]
# enter container
docker attach [container-name]
# see all running containers
docker ps -a

# status of running only container(s)
docker ps
# stop container, outside of docker
docker stop [container-name]
# delete container
docker rm [container-name]
# docker service status of docker engine
docker info
service docker status

# start docker engine
service docker start

Docker hub search in google: hub.docker.com

# stop & exit container
exit

# give name to a container
docker run -it --name [give name] /bin/bash

Some important commands:

# Stop all running containers
docker stop $(docker ps -a -q)

# Delete all stopped containers
docker rm $(docker ps -a -q)

# Delete all images
docker rmi -f $(docker images -q)