-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change getExposedPorts to return port w/ protocol #349
Conversation
commands/start-container.ts
Outdated
@@ -29,7 +29,7 @@ export async function startContainer(context?: ImageNode, interactive?: boolean) | |||
docker.getExposedPorts(imageToStart.Id).then((ports: string[]) => { | |||
let options = `--rm ${interactive ? '-it' : '-d'}`; | |||
if (ports.length) { | |||
const portMappings = ports.map((port) => `-p ${port}:${port}`); | |||
const portMappings = ports.map((port) => `-p ${port.split("/")[0]}:${port}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please comment with what you're expecting and the output you're going for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current output:
-p 8080:8080
output I'm going for:
-p 8080:8080/tcp
, -p 3010:3010/tcp
Notice the difference in 8080/tcp. Earlier, we stripped the protocol when returning the function (see getExposedPorts
).
The earlier command was:
docker run --rm -d -p 8080:8080 node-todo:latest
Now with the change:
docker run --rm -d -p 8080:8080/tcp node-todo:latest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted code comments. If you need to explain it to me, you need to explain it to code maintainers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, my bad. Added comment
commands/start-container.ts
Outdated
@@ -29,7 +29,7 @@ export async function startContainer(context?: ImageNode, interactive?: boolean) | |||
docker.getExposedPorts(imageToStart.Id).then((ports: string[]) => { | |||
let options = `--rm ${interactive ? '-it' : '-d'}`; | |||
if (ports.length) { | |||
const portMappings = ports.map((port) => `-p ${port}:${port}`); | |||
const portMappings = ports.map((port) => `-p ${port.split("/")[0]}:${port}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there are testcases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Fixes #284