Skip to content

Proposal: show container IP address with docker ps command #8786

@syabro

Description

@syabro

Maybe with key --ips, but it'll be very useful for debugging builds

Activity

cpuguy83

cpuguy83 commented on Oct 27, 2014

@cpuguy83
Member

I don't see the purpose of adding this to docker ps.
See docker inspect <container> for this information.
or docker inpspect --format '{{ .NetworkSettings.IPAddress }}' <container>

syabro

syabro commented on Oct 27, 2014

@syabro
Author

I know about docker inspect with format
But it'll be much simpler. I need it often and to do it I need:

  1. run docker ps to copy id/name
  2. google this "beautiful" command
  3. paste both of them
    Too much actions
cpuguy83

cpuguy83 commented on Oct 27, 2014

@cpuguy83
Member

or docker inspect --format '{{ .ID }} - {{ .Name }} - {{ .NetworkSettings.IPAddress }}' <container>
This enables you to do a lot of stuff.

syabro

syabro commented on Oct 27, 2014

@syabro
Author

I still need to do 3 actions instead of one :)

cpuguy83

cpuguy83 commented on Oct 27, 2014

@cpuguy83
Member

Why?

syabro

syabro commented on Oct 27, 2014

@syabro
Author

@brianm a) found your answer or copypaste it somewhere
b) found docker id
c) run it ^_^

NomAnor

NomAnor commented on Oct 27, 2014

@NomAnor

A little shell magic for you:

alias dps="docker ps -q | xargs docker inspect --format '{{ .Id }} - {{ .Name }} - {{ .NetworkSettings.IPAddress }}'"
syabro

syabro commented on Oct 27, 2014

@syabro
Author

@NomAnor wow
thanks
I owe you a beer

ajohnstone

ajohnstone commented on Jan 21, 2015

@ajohnstone

This will retain the formatting from docker ps
I've added a few more here aliases below, hope that helps.

https://github.com/ajohnstone/dot-files/blob/master/bash.d/bash/docker

function docker-ips() {
    docker ps | while read line; do
        if `echo $line | grep -q 'CONTAINER ID'`; then
            echo -e "IP ADDRESS\t$line"
        else
            CID=$(echo $line | awk '{print $1}');
            IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $CID);
            printf "${IP}\t${line}\n"
        fi
    done;
}
IP ADDRESS  CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
172.17.0.10 2a59d5309caf        ubuntu:latest       "bash"              10 minutes ago      Up 10 minutes                           suspicious_bartik
172.17.0.9  3749630c1a10        ubuntu:latest       "bash"              10 minutes ago      Up 10 minutes                           tender_pasteur
172.17.0.8  14c0677bb489        ubuntu:latest       "bash"              10 minutes ago      Up 10 minutes                           silly_poincare

added
kind/enhancementEnhancements are not bugs or new features but can improve usability or performance.
kind/featureFunctionality or other elements that the project doesn't currently have. Features are new and shiny
and removed
kind/enhancementEnhancements are not bugs or new features but can improve usability or performance.
on Feb 27, 2015
davsclaus

davsclaus commented on Mar 9, 2015

@davsclaus

+1

A shame there is no vote on github issues.

Pensu

Pensu commented on Mar 10, 2015

@Pensu
Contributor

+1

I have wanted it for a long time!
On 03/09/2015 09:00 PM, Claus Ibsen wrote:

+1

A shame there is no vote on github issues.


Reply to this email directly or view it on GitHub:
#8786 (comment)

Peeyush Gupta
gpeeyush@linux.vnet.ibm.com

26 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/clikind/featureFunctionality or other elements that the project doesn't currently have. Features are new and shiny

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @syabro@uocnb@ajohnstone@analytically@cben

      Issue actions

        Proposal: show container IP address with docker ps command · Issue #8786 · moby/moby