Basic Commands Of Docker Client

Image Lifecycle Management

Docker Images acts as a blueprint for building docker containers. Images are immutable, meaning the can’t be modified directly. Instead, new image is created based on changes. Following are steps for Docker Image Lifecycle Management along with commands.

1. Creating an Image

An Image is created using a Dockerfile. This file contains all instructions needed for building the required image.

$ docker build -t my-custom-image .

2. Tagging an Image

After creating an image, it can be assigned a tag. This acts as a label making it easier to reference and differentiate between different versions.

$ docker tag my-custom-image:latest my-custom-image:v1

3. Pushing an Images to Registry

Created images can be pushed to a Docker registry, this could be a public registry like Docker Hub or any other private registry.

$ docker push my-registry/my-custom-image:v1

4. Pulling an Image from Registry

Images can be pulled from remote registry, which could be public one like DockerHub or a private one.

$ docker pull my-registry/my-custom-image:v1

5. Running a containers from an Image

Docker can create an a running container based on an image. Unless committed the chages made in the container do not persist.

$ docker run -d –name my-container my-custom-image:v1

6. Inspecting an Image

Inspecting a docker image will reveal its details, including layers, labels, environment variables, and much more.

$ docker image inspect my-custom-image:v1

7. Removing unused Images

The residual images quickly pile up, so unused or outdated images can be removed using the following command:

$ docker image rm my-custom-image:v1

Container Lifecycle Management

It is important to understanding the lifecycle of Docker containers. Here we will go through each step of container lifecycle for creation to management to deletion.

1. Creating a container

This is done using the docker create command. This step will initialize the container but does not actually start it.

$ docker create –name my-example-container ubuntu

2. Starting a container

containerA contianer can be started using docker start command. This step will run the created container.

$ docker start my-example-container

3. Pausing and Unpausing the container

A container can be paused/unpaused using the very obvious docker pause / docker unpause command. This is helpful to temporarily suspend the container’s execution without actually having to destroying it.

$ docker pause my-example-container

$ docker unpause my-example-container

4. Stopping the container

A containre can be stopped using the docker stop command. Running this command will shuts down the container.

$ docker stop my-example-container

5. Restarting the container

A container can be restarted using the docker restart command. This will stops and then starts the container again.

$ docker restart my-example-container

6. Killing the container

A container can be killed using the docker kill command. This command will forcefully terminate a running container.

$ docker kill my-container

7. Removing the container

A container can be removed using the docker rm command. Running this command will remove everything associated with this container.

$ docker rm my-container

Miscellaneous Docker Commands

1. Checking Version

This displays the version of local Docker installation

$ docker version

2. Login / Logout

Use this command to login / logout from a particular docker registry account.

$ docker login

$ docker logout

3. Checking Info

This command is used to get information about Docker system, including details about containers, images, networks, etc

$ docker info

4. Inspecting Object

This docker command allows to retrieve low level information about any Docker objects. Object here could be anything from containers, volumes, networks, etc. ID or the name also needs to be passed.

$ docker inspect <ID>

Note: Replace <ID> with the actual name or ID of the object

What Is Docker Client ?

Docker is rapidly growing in popularity. It is an open platform based on OCI, Open Container Initiative. The containerization helps separate applications from the underlying infrastructure. Thus, enabling rapid software development and release.

Docker Client is the frontend that enables users to interact with the docker ecosystem, In this article we will learn about Docker Client, its uses, how it works, and compare it to other docker components.

Similar Reads

What is a Docker Client?

The Docker client is the primary interface for interacting with the underlying Docker Ecosystem. It can be used as a command line tool, docker client, or as a Docker Desktop, which is a stand-alone graphical application available for Windows, MacOS, and Linux....

How does Docker Client Work?

As the name suggests interface Docker Client is a part of Docker’s Client Server Architecture. The Docker Client abstracts the underlying complexity and provides users with a simple front end. This could be a graphical interface as Docker Desktop or a command line tool as Docker CLI....

Use Cases Of Docker Client

1. Container Management...

Basic Commands Of Docker Client

Image Lifecycle Management...

Security Best Practices

It is important to undertand and follow the Security best practices for Docker, here we’ll be discussing a few of the essentail ones....

Docker Client VS Docker Daemon

The Docker Client provides the interface through which users interact with Docker. While, Docker daemon actually does the heavy lifiting behind all of dockers operations.The docker daemon is a long running background service that acts as server process on the system. While, Docker Client could run on the same machine or remotely. Users must be a part of docker group, having elevated privileges to use Docker Client. On the other hand, Docker Daemon needs to runs with root privileges to provision system resources....

Docker CLI vs Docker Desktop

Docker CLI is the command-line interface for Docker. It is fast and lightweight making it ideal for quickly running commands. This could also be extented with other commands to be used for scripting, automation, and server environments....

Docker Client – FAQ’s

Can Docker client be used remotely?...