Here you can learn about the docker basic and its commands
The docker run command is used to get the specific docker image from registry and start and run the container of the image.
For this example, the alpine docker image is used as it is more light weight linux image.
docker run alpine:3.4 uptime
Here the apline is a public image and it will be pulled from registry and created the container and started the container and ran the 'uptime' and exit.
To log into container, run following command.
docker run -it alpine:3.4 sh
To keep the container in running state in detach mode, execute continuously running command.
For example
docker run -d alpine:3.4 ping www.google.com
To check the last ran container status.
docker ps -l
To see all the containers.
docker ps -a
To see only the last two containers.
docker ps -n 2
Container can be started using following command with container id or name.
docker start <container_id / container_name>
Container can be stopped using following command with container id or name.
docker stop <container_id / container_name>
Container can be removed using following command with container id or name.
docker rm <container_id / container_name>
docker logs <container_id / container_name>
docker network ls
docker exec -it <container_id / container_name> /bin/bash
docker build -t <image name and version> .
docker images
docker rmi <image id>
You can find all the detail about the container
eg ip
docker inspect <container id>
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container id>