DockerSetupAWS - amresh087/newronaRepos GitHub Wiki
After connect ec2 machine then run command
uname -r
this command give all details of Linux machine which kernel version is used in this system.
sudo yum -y update
sudo yum install -y docker
After install docker then verified type command
docker
docker --version
Now first start docker service
sudo service docker start
Now you can check all command of docker
sudo docker info
Now if you want stop docker service
sudo service docker stop
Now if you want remove docker
sudo yum remove docker
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce
sudo systemctl status docker
sudo usermod -aG docker ${USER}
Now if you want stop docker service
sudo service docker stop
close terminal then open new terminal
Now you add uses to the docker group so the no need to ever time type sudo command for run docker command
sudo usermod -a -G docker ec2-user
in this command ec2-user is user id
Note-->> Remember that after run above command that now work same terminal so you disconnect your putty then again connect now it is working.
-
docker version
This is command give information docker client and docker engine
-
docker -v
This is gives us only docker version you can also use docker --version
-
docker info
This command will give you little details information about docker
-
docker --help
This is very useful command its can use get information for any other command for example you can use docker images --help , docker run --help , docker login --help
-
docker login This command use you can login in your dockerhub.com with what are you user name and password created in dockerhub
-
docker images
This gives list of all images.
-
docker pull
This is use pull image from docker hub repository.for example docker pull ubuntu
-
docker rmi
This is use for remove images you can check all command docker rmi --help
But if you want remove image from docker then use command docker rmi
-
docker ps
In docker ps now show all command so use docker ps --help If you use docker ps that is give running container only if you want show all container list then use docker ps -a
-
docker run
This command is use for run images for example docker run ubuntu if image is not in local docker then pull from Docker Hub
docker run -it ubuntu
Here -it is interactive mode That means now you will have bash session inside the container, so you can ls, mkdir, or do any bash command inside the container. So the by default you enter in bash mean if you want run docker command then open new terminal.
Otherwise you can use exit for come outside of container
Note--> while running ubuntu image then first run docker run -it ubuntu then created container id now close putty and again open putty now run docker ps then you can find container id.After that you can use docker star container_id and docker stop container_id
-
docker start
After run images then its created docker container id. Now you can use container id for start and stop
docker start container_id
-
docker stop
Same like start command you can also use stop command
docker stop container_id
-
docker stats
This command is use for check memory uses and cpu uses, the input output. Now press ctrl+C then you can come out side.
-
docker system df
If you want check disk uses of docker then it can show images size, container size, local volumes size and Build Cache
-
docker system prune
This command is use remove unused data docker system prune like you can say if container is not running then its remove, if volume is not used by any container then volume also remove and image is not used by any container then images is also remove.