jpetazzo / pipework

Software-Defined Networking tools for LXC (LinuX Containers)
Apache License 2.0
4.22k stars 727 forks source link

Allow to specify containers by name instead of by id #21

Closed jpetazzo closed 10 years ago

jpetazzo commented 10 years ago

To address a suggestion in #16.

helander commented 10 years ago

I think I can do this, at least I have an idea of how it could be done.

jpetazzo commented 10 years ago

That would be awesome!

helander commented 10 years ago

I have tested the following the following modification and it seems to work fine. I am a bit short of time, so if someone would like it, please modify your local copy (or submit a proper update via git).

The line that says:

GUESTNAME=$2

should be replaced by:

GUESTNAME=$(docker inspect -format='{{.ID}}' $2)

The proper solution should also support non-docker users, so a bit more coulding would be required. Something like this might work:

GUESTNAME=$2 [ "which docker" ] && { GUESTNAME=$(docker inspect -format='{{.ID}}' $2) }

/Lars

themgt commented 10 years ago

I've just been doing it like this: pipework $BRIDGE $(docker ps | grep $GUESTNAME | awk '{print $1}') $IP_CIDR

helander commented 10 years ago

I would prefer using docker inspect, instead of the depencency on grep, awk and docker ps output formatting.

jpetazzo commented 10 years ago

I've only tested minimally, but it looks like this should work :-)

helander commented 10 years ago

:)