As we have discussed at length, the key to start working with any docker container is using images. There are many freely available images shared across docker image index and the CLI allows simple access to query the image repository and to download new ones.
When you are ready, you can also share your image
there as well. See the section on “push” further down for details.
Searching for a docker image:*
# Usage: sudo docker search [image name]
sudo docker search ubuntu
This will provide you a very long list of all available images matching the query: Ubuntu.
Downloading (PULLing) an image:
Either when you are building / creating a container or before you do, you will need to have an image present at the host machine where the containers will exist. In order to download images (perhaps following “search”) you can execute pull to get one.
# Usage: sudo docker pull [image name]
sudo docker pull ubuntu
Listing images:
All the images on your system, including the ones you have created by committing (see below for details), can be listed using “images”. This provides a full list of all available ones.
Committing changes to an image:
As you work with a container and continue to perform actions on it (e.g. download and install software, configure files etc.), to have it keep its state, you need to “commit”. Committing makes sure that everything continues from where they left next time you use one (i.e. an image).
# Usage: sudo docker commit [container ID] [image name]
sudo docker commit 8dbd9e392a96 my_img
Sharing (PUSHing) images:
Although it is a bit early at this moment - in our article, when you have created your own container which you would like to share with the rest of the world, you can use push to have your image listed in the index where everybody can download and use.
Please remember to “commit” all your changes.
# Usage: sudo docker push [username/image name]
sudo docker push my_username/my_first_image
Note: You need to sign-up at index.docker.io to push images to docker index.