Working with images using APIs
As mentioned earlier, Docker internally uses the Docker engine API to fulfill all our containerization need
s. In this recipe, we will be using the curl
command and the Docker engine APIs to perform various operations on the Docker images.
How to do it...
In this recipe, we'll look at a few image operations, as follows:
- To list images, use the following API:

Here is an example of the preceding syntax:

- You can create an image by pulling it from any registry or tar file using the following API:

The /images/create
API supports a few options, as listed next, to work with images:

Now let's look into a few examples:
- Get the
cookbook/apache2
image from Docker Hub:
$ curl -X POST \ --unix-socket /var/run/docker.sock \ http:/images/create?fromImage=cookbook/apache2
- Get the WordPress image with the
latest
tag:

- Create an image from the
tar
file:

In this example, we chose to upload the image as a tar bundle from the Docker host using the --data-binary
option of the curl
command...