Debug School

Gaurav Pathak
Gaurav Pathak

Posted on

Day2- Docker Command By Gaurav Pathak

Some Docker Commands
• cp
• diff
• rename
• port
• update
• wait
• logs
• events
• top
• inspect
Docker commands for images
• docker images
• docker pull
• docker info
• docker rmi
• docker inspect
• docker commit – m “message” – a”name” container id alias name

Steps to create a docker images with java and apache installed
docker run -itd ubuntu
docker exec -it “containerid” /bin/bash
install java
apt-get update
apt-get install openjdk-11-jdk -y
apt-get install openjdk-11-jdk-headless -y
install apache
apt-get install apache2 -y
Install wget
apt-get install wget -y
Install war file
wget https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war
chmod 755 sample.war
commit the image
docker commit -m"my first commit" -a"gaurav" containerid name
docker images
Validate java and apache
docker exec containerid java
docker exec containerid which apache2
docker exec containerid ls /opt/

After committing to save file in tar

  • docker save -o image.tar name of image

To load the image which is saved as tar,

  • docker load -i name.tar:

Check the images using docker images command to see if the tar is loaded.
To share the image with large group we can push our image to docker repository
Create an account in docker hub
Login to docker hub
docker login
provide username and password
tag the image matching to repo name
docker tag image /gauravpathakddn/devopstraining
Push the image to repo
docker push /gauravpathakddn/devopstraining

Top comments (0)