Docker client and some of its commands (June 15, 2017)


Docker client and some of its commands

 

docker client

In order to start working with Docker images and containers through the command line, we need Docker client. Docker client is a tool that interacts with Docker engine (Docker Daemen).

You can think of Docker daemon as the engine that ultimately can control accessing our containers that are running. Docker client will let us work with images, and then convert those images into running containers, and so let's look at some of the different commands that we can use with this particular tool.

As mentioned this tool is going to allow us to interact with the Docker engine, the Docker daemon that is running behind the scenes. Using this tool, we can build and manage images, we can then take those images, run and manage containers and all of this will be running on Docker host that could be Linux or recently Windows Server 2016 or higher.

So let's look at some of the commands that you could use as you start to work with Docker client. There are quite a few that you can run and we will see some of them.

 

Docker help

In order to see all available commands you can use docker help e.g. docker help

If you want to be more specific e.g. on run command you would say docker run –help and this gives you all options on how to use docker run command.

Docker pull

Docker Pull is one of the big ones you will use. You might find a nginx  image or an ASP.NET or PHP or whatever it may be, you might have an image up in Docker hub and you want to pull that from Docker hub down to your development environment. We can use docker pull command to do that.

Example: docker pull nginx

 

Docker run

Once we have an image, we can run it.  We can use Docker run to do that. We simply say docker run and then give it the name of the image that we want to run.

Example:  docker run -it --memory 1g --cpu-percent 20 nginx

 

Docker images

We can also list of our images by simply running docker images.

 

Docker ps

When our image comes to containers, we can run docker ps and this will list all of the different containers that we might have available.

Example: docker ps

 

Once we have containers and the images and everything available, we can then start containers, we can stop containers and do all kinds of things. In addition to above commands, I found below commands useful when working with Docker:

docker build: Builds an image from a Dockerfile

docker exec: Runs a command in a running container

docker info: Displays system-wide information

docker inspect: Returns low-level information on a container, image or task

docker login: Logs in to a Docker registry.

docker logout: Logs out from a Docker registry.

docker logs: Fetch the logs of a container

docker push: Push an image or a repository to a registry

docker rm: Removes one or more containers

docker rmi Removes one or more images

docker start: Starts one or more stopped containers

docker stop: Stop one or more running containers

docker tag: Tag an image into a repository

docker version:   Show the Docker version information

docker volume: Manage Docker volumes

Back to All Articles