Docker basic commands for beginners:
- dicker ps
- To see running docker processes.
- docker ps -a
- To see all the docker processes, including stopped ones.
- docker exec -it czcmysql /bin/bash
- To login into particular container, here czcmysql is mysql’s container name, you can also use container id instead of name to login.
- docker image ls
- List all docker images.
- docker container ls
- List all docker containers.
- sudo docker start czcbackend
- To start a particular docker container, here czcbackend is my container’s name.
- sudo docker stop czcbackend
- To stop a particular docker container, here czcbackend is my container’s name.
- sudo docker restart czcjenkins
- To restart a particular docker container, here czcjenkins is my jenkins container name.
- sudo docker logs czcbackend
- To see the logs details of a particular docker container, here czcbackend is my container’s name.
- sudo docker logs czcbackend -f
- To monitor the logs details of a particular docker container, here czcbackend is my container’s name.
- sudo docker logs czcbackend | grep ‘nullpointerexception’
- To monitor the logs details with the text “nullpointerexception” of a particular docker container, here czcbackend is my container’s name.
- sudo docker rm d724fc6c512c31585bfeebccce1196df09cdc3c9152f01eb627aa3c198982c09
- Removing docker container
- sudo docker inspect container_id
- Gives detailed information about the container.
- sudo docker cp callmeuissr.sh czcjenkins:/var/jenkins_home/script/
- This copies the callmeuissr.sh file from your current linux machine location to your docker container named czcjenkins and in this path /var/jenkins_home/script.
- docker container exec -u 0 -it czcjenkins bash
- This command can be used something similar to this functionality, (getting into container called czcjenkins (for jenkins) and update the war file(jenkins docker container update)).
- If you are looking for the complete docker jenkins update details, then this medium post can help you.
This can be verified by proceeding the below way:
- sudo docker exec -it czcjenkins /bin/bash (getting into czcjenkins docker container)
- cd /var/jenkins_home/script (going into the pasted path)
- ls (will show the list along with your copied file callmeuissr.sh file)
Can I clean up docker overlay2 folder ?
This will contain lot of stuffs used by the docker, it is bit difficult to identify which is not needed by you, so always proceed with system prune command mentioned below to safely remove the unused stuffs by docker.
How to clean up the docker (like stopped containers, unused stuffs etc.) ?
docker system prune
543 total views, 3 views today