Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Implement printing published ports #98

Merged
merged 3 commits into from
May 18, 2020
Merged

Implement printing published ports #98

merged 3 commits into from
May 18, 2020

Conversation

rumpl
Copy link
Contributor

@rumpl rumpl commented May 15, 2020

❯ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                  PORTS                                                  NAMES
9126fca893ca        nginx               "nginx -g 'daemon of…"   23 seconds ago      Up Less than a second   0.0.0.0:80->80/tcp, 0.0.0.0:8000-9000->8000-9000/tcp   hopeful_banzai
❯ ./bin/docker --context moby ps
CONTAINER ID        IMAGE        COMMAND                       STATUS                       PORTS
9126fca893ca        nginx        nginx -g 'daemon off;'        Up Less than a second        0.0.0.0:80->80/tcp, 0.0.0.0:8000-9000->8000-9000/tcp

azure/convert/ports.go Outdated Show resolved Hide resolved
Copy link
Contributor

@chris-crone chris-crone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Makefile Outdated Show resolved Hide resolved
cli/cmd/ps.go Outdated Show resolved Hide resolved
}

// PortsString returns a human readable published ports
func PortsString(ports []containers.Port) string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case it's useful, I implemented some presentation logic for ports in the CLI a while back (see docker/cli#581)

I also recently discovered that there's a weird discrepancy between services and containers when publishing port-ranges (still to investigate further);

For a service (docker service create);

-p 8080-8090:80 means: map container port 80 to ports 8080 - 8090 on the host

For a container;

-p 8080-8090:80 means: map container port 80 to the first available port within 8080 - 8090

I never realised this discrepancy was there tbh (as mentioned; need to investigate further if this was on purpose or an oversight)

Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rumpl rumpl merged commit 0c6b6be into master May 18, 2020
@rumpl rumpl deleted the feat-port-print branch May 18, 2020 11:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants