Being a newbie to docker, I thought of sharing some useful commands running
docker.
-
List the images
sudo docker image ls
-
List the running containers
sudo docker container ls
-
Build and tag a docker image
sudo docker build -t <name_of_the_image> .
-
Run a docker image
sudo docker run -p 8888:8080 <name_of_the_image>
-
Check the java version running on a container
First list the containers usingsudo docker container ls
Then execute the following command to check the running java version of the container. You have to use the container id obtained from the previous output.
sudo docker exec <container_id> java -version
-
Delete Container
sudo docker container rm <container_id>
-
Delete Image
sudo docker image rm <image_id>
Hope it helps.
Thanks.