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

Extend docker container update to support updating ports #5013

Open
AkihiroSuda opened this issue Apr 13, 2024 · 1 comment
Open

Extend docker container update to support updating ports #5013

AkihiroSuda opened this issue Apr 13, 2024 · 1 comment

Comments

@AkihiroSuda
Copy link
Collaborator

Description

Motivation

Usernetes Gen2 (Kubernetes in Rootless Docker) currently requires all the ports to be hard-coded in docker-compose.yaml, and the port list cannot be updated without restarting the entire Kubernetes node container:
https://github.com/rootless-containers/usernetes/blob/gen2-v20240410.0/docker-compose.yaml#L13-L21

Extending docker container update to support modifying ports will allow dynamically updating the port list without restarting the entire Kubernetes node container.

This should be useful for other Kubernetes-in-Docker, Docker-in-Docker, and similar stacks.

CLI syntax designs

Option A: docker container update CONTAINER --add-publish=NEWPORT

Example: remove 8080:81, keep 8081:81 untouched, add 8082:82

docker container run --name=foo -p 8080:80 -p 8081:81 foo
docker container update foo --remove-publish=8080 --add-publish=8082:82

Example: remove all the ports

docker container update foo --remove-publish=8081 --remove-publish=8082

Option B: docker container portx add CONTAINER NEWPORT

Example: remove 8080:81, keep 8081:81 untouched, add 8082:82

docker container run --name=foo -p 8080:80 -p 8081:81 foo
docker container portx remove foo 8080
docker container portx add foo 8082:82

Example: remove all the ports

docker container portx remove foo 8081 8082

Option C: docker container update CONTAINER --publish=PORT ...

Example: remove 8080:81, keep 8081:81 untouched, add 8082:82

docker container run --name=foo -p 8080:80 -p 8081:81 foo
docker container update foo -p 8081:81 -p 8082:82

Example: remove all the ports

docker container update foo -p none
@Anish-M
Copy link

Anish-M commented May 5, 2024

Hi, working on this issue right now, the client api to update using updateConfig doesn't have PortBindings as a field in the updateConfig struct and the only way to update the ports is by calling ContainerUpdate with a modified host Config on the daemon, do you know how I could get the daemon object from the daemon string?

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