We're finishing today the series of articles in which we have advanced a small part of the Containers for Developers and Quality Assurance training course from The Linux Foundation. In previous posts, we talked about how to build container blocks, configuring Docker environment and Docker Machine. In this post we are going to introduce some basic commands to operate with containers and Docker images.
To perform container operations, we should first connect to our "dockerhost" with Docker Machine. Once connected, we can start the container in interactive mode and explore the different processes inside the container.
For example, the command "docker container ls" lists the containers being executed. With the command "docker container inspect" we can inspect an individual container. Using the command "docker container exec" we can start a new process inside a container which is already running and perform some operations. We can use the "docker container stop" command to stop a container and delete a container that is no longer active using the command "docker container rm".
To perform operations with Docker image, first we should also make sure that we are connected to our "dockerhost" with Docker Machine, so that all Docker commands are executed in the "dockerhost" that runs on DigitalOcean cloud.
The basic commands that are needed in this case are similar to the previous ones. With the command "docker image ls" we obtain a list of the available images in our "dockerhost". Using the command "docker image pull" ** we can extract an image from our Docker Registry. And we can remove an image from "dockerhost" using the "docker image rm" command.