Autopull a list of Docker images
Grabbing Docker images can be tedious. Especially grabbing multiple images. So now, we are going to see how we can pull a number of Docker images at the same time using the Python library for Docker:
- First, install the Docker Python library in a virtual environment using the following command:
pip install docker
2. Then, write a script in a file called docker_pull.py to loop through a list of image names and pull them by leveraging the Docker library:

Figure 2.14 – Code to pull Docker images
3. After this, run the file using this command:
python docker_pull.py
You can then run the docker images command to check out the Docker containers that you may have locally:

Figure 2.15 – List of Docker images
So, this gives you a pretty nifty way to get the Docker containers you want with the tags that you want on them.
Summary
Python is not just about writing code; it is about a coding philosophy – a philosophy that has made Python incredibly popular among DevOps engineers. The writing of the Zen of Python affected the way that the language was developed, and we still see the consequences today in both Python and DevOps. Python’s philosophy offers the DevOps realm the programming language that fits its philosophy.
Python has numerous uses that facilitate a lot of DevOps tasks. So, hopefully, this chapter has given you some insights into what makes Python such a good companion for DevOps. In the next chapter, you will see that companionship in action and learn how to use your knowledge in a truly hands-on way.