How to specify a port on docker deploy

I can specify the container port with service_port but it always maps it to a (random?) port on the host.

Is there a way to specify both container port and host port?


Based on the reviewing the Docker Platform plugin code, it looks like the host ports are not configurable.

What scenario have you encountered where it is ideal to be able to set the host port? Something like having a predictable port for a load balancer pointing at the docker host?

I’m deploying a container to a remote instance that has Docker running, the host port is fixed (no load balancer yet, but the port is whitelisted).

This seems pretty common to me, I wonder if there’s any workaround.

Yes, there may be a work-around until the Docker plugin makes it possible to specify this option. For now you could use the exec plugin as demonstrated in the kubectl apply example but reference a script template that executes docker run with the parameters you want instead. I don’t believe there would be a way to dynamically set the port easily with waypoint.hcl, but you can set it explicitly in the templated file.

Thanks @jbayer, a few open questions on this:

  1. is what I’m trying to achieve that weird? seems like a really common case to me, deploying to a remote docker host where you need to know on which port your app runs.

  2. if the answer is “yes”, what would be an alternative to this? using kubernetes?

No, what you’re asking about is not strange, the Docker plug-in is incomplete currently.

If you used Kubernetes, it would require you to hook up whatever ingress solution you are using (eg a load balancer) to the k8s service associated with the app.

In my case, I need to expose 2 ports, one for the service and one for remote debugging. Is there any workaround for that?