docker version
docker info
Note
- Docker images can be downloaded from Docker hub using docker commands.
Lets pull an image from docker hub using pull command.
docker pull <<image name>>
e.g. docker pull nginx
docker images ↵
docker history <<Image Name>> ↵
e.g. docker history nginx
docker rmi <<Image Name>> ↵
e.g. docker rmi nginx
docker run <<Image Name>> ↵
e.g. docker run --name nginxservice -d nginx
--name --> to specify a name for the running service. In this example, it is nginxservice
-d --> to run the service in the background
- We can also search for the images in the Docker Hub registry by using docker search subcommand. Let us search for ubuntu images in the Docker Hub, and limit the search result only to 20 because we have more than 2000 images on Ubuntu:
docker search ubuntu | head -20
docker ps
docker inspect <container name> ↵
eg: docker inspect nginxservice
docker stats running <<container name>> ↵
e.g. docker stats nginxservice
docker pause <<container name>> ↵
e.g. docker pause nginxservice
docker unpause <<container name>> ↵
e.g. docker unpause nginxservice
docker kill <<container name>> ↵
e.g. docker kill nginxservices
docker start <<Container Name>> ↵
e.g. docker start nginxservice
docker stop <<Container Name >> ↵
e.g. docker stop nginxservice
docker ps -a
docker rm <<Container Name >> ↵
e.g. docker rm nginxservice
docker container prune
Note:
- Instead of using the Container Name, all the above commands can be executed with the container id as well.
docker export <<Container Name>> <<file_Name>>.tar ↵
e.g.
- Lets run a service using docker run command.
docker run --name newnginxservice -d nginx
docker export newnginxservice > test.tar
docker import <<Remote URL/Image Name.tar>> ↵
e.g. docker import test.tar
service docker stop
service docker start
Note:
- You may not be able to try these 2 commands since you would not have access to root on Katacoda playground.
In case you are having a problem with downloading the images and running them, please follow these steps to check whether the docker service is running on your system or not:
- Check the running status of docker:
service docker stats
- Restart Docker service in your system:
service docker restart