Skip to content
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

Consider changing Docker image to use both ENTRYPOINT and CMD #1279

Closed
jander-msft opened this issue Jan 5, 2022 · 2 comments
Closed

Consider changing Docker image to use both ENTRYPOINT and CMD #1279

jander-msft opened this issue Jan 5, 2022 · 2 comments
Assignees
Milestone

Comments

@jander-msft
Copy link
Member

jander-msft commented Jan 5, 2022

Problem

Currently, the Dockerfile describes the startup of the container as follows:

ENTRYPOINT [ "dotnet-monitor", "collect", "--urls", "https://+:52323", "--metricUrls", "http://+:52325" ]

This works fine if the container is run as-is or by an orchestrator that doesn't attempt to override the arguments.

However, take an example where a user attempts to remove HTTPS usage from the default URL via Kubernetes deployment by using the args property on the container spec:

args: [ "--urls", "http://*:52323", "--metricUrls", "http://*:52325" ]

What actually happens is that the following is executed when starting the container:

dotnet-monitor collect --urls https://+:52323 --metricUrls http://+:52325 --urls http://*:52323 --metricUrls http://*:52325

Which is going to fail for two reasons: the original https://+:52323 will fail to bind because a certificate was not configured and the second metricsUrls value fails to bind because 52325 is already in use. It's not obvious why these would fail given that the user attempted to override the parameters of the container.

The root of the issue is how Kubernetes overrides the startup values for Docker and how the Dockerfile has described those values:

  • Kubernetes' command property will override Docker's ENTRYPOINT statement
  • Kubernetes' args property will override Docker's CMD statement

Thus, to truly override the command line arguments, users need to specify command in their Kubernetes deployments:

command: [ "dotnet-monitor", "collect", "--urls", "http://+:52323", "--metricUrls", "http://+:52325" ]

Proposal

It might be beneficial to change the Dockerfile to split the arguments from the entrypoint so that they are more easily overridable:

ENTRYPOINT [ "dotnet-monitor" ]
CMD [ "collect", "--urls", "https://+:52323", "--metricUrls", "http://+:52325" ]

This allows users to override the arguments to the tool. Thus, if a user specifies the following in a Kubernetes deployment:

args: [ "collect", "--urls", "http://localhost:52323", "--no-auth" ]

then the effective execution within the container is:

dotnet-monitor collect --urls http://localhost:52323 --no-auth
@kelltrick
Copy link
Contributor

My alternate proposal is to break out everything (including collect) into the CMD:

ENTRYPOINT [ "dotnet-monitor" ]
CMD [ "collect", "--urls", "https://+:52323", "--metricUrls", "http://+:52325" ]

@jander-msft
Copy link
Member Author

My alternate proposal is to break out everything (including collect) into the CMD:

ENTRYPOINT [ "dotnet-monitor" ]
CMD [ "collect", "--urls", "https://+:52323", "--metricUrls", "http://+:52325" ]

I've updated the issue to reflect your proposal (which is how it was implemented in dotnet/dotnet-docker#3524).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants