Site icon NgDeveloper

Docker commands for new Devops Engineers

Docker basic commands for beginners:

We have a command something like this for dangling images/none images/dangling volumes.

docker images –filter dangling=true -qa

This is something which docker uses intermittently to create the requested docker and left as it as after the completion of that operation, but you can go ahead and prune it if you required.

To Restart all the running docker containers:

This can be verified by proceeding the below way:

  1. sudo docker exec -it czcjenkins /bin/bash (getting into czcjenkins docker container)
  2. cd /var/jenkins_home/script (going into the pasted path)
  3. 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 (but this removes all the not used containers/images, personally I ran and removed my stopped container which is needed for me, so use system prune docker command with your own risk.)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

docker system prune

Please refer this link for detailed understanding on do’s and don’t.

How to export the docker container?

sudo docker export czcjenkins > czcjenkins.tar

Here czcjenkins is my docker container name.

How to backup and restore mysql running on docker containers ?

Backup

docker exec ngmysql /usr/bin/mysqldump -u root --password=MYSQL_PASSWORD ngdeveloper > ngdeveloper_Aug8_2019.sql

Restore

cat ngdeveloper_Aug8_2019.sql | docker exec -i ngmysql /usr/bin/mysql -u root --password=MYSQL_PASSWORD ngdeveloper

How to restart all docker containers at once?

sudo docker restart $(docker ps -a -q)
Exit mobile version