且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何基于图像过滤码头过程

更新时间:2023-11-22 22:58:10

您可以使用awk和grep过滤指定的容器ID。
例如:



docker ps | grepdocker-mariadb:1.0.1| awk'{print $ 1}'



这将打印您的容器的ID。


I have been trying to get the container id of docker instance using docker process command, but when i'm trying with filter by name it works fine for me.

sudo -S docker ps -q --filter="name=romantic_rosalind"

Results container id :

3c7e865f1dfb

But when i filter using image i'm getting all the instance container ids :

sudo -S docker ps -q  --filter="image=docker-mariadb:1.0.1"

Results Container ids :

5570dc09b581

3c7e865f1dfb

But i wish to get only container id of mariadb.

How to get container id of docker process using filter as image ?

You can use awk and grep to filter specified container id. For example:

docker ps | grep "docker-mariadb:1.0.1" | awk '{print $1}'

This will print id of your container.