# How to specify a port on docker deploy

**URL:** <https://discuss.hashicorp.com/t/how-to-specify-a-port-on-docker-deploy/16520>\
**Category:** Waypoint\
**Created:** [October 22, 2020, 6:31pm UTC](https://discuss.hashicorp.com/t/how-to-specify-a-port-on-docker-deploy/16520 "2020-10-22T18:31:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fernandezpablo85](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/fernandezpablo85/32/13776_2.png) [@fernandezpablo85](https://discuss.hashicorp.com/u/fernandezpablo85)\
**Post date:** [October 22, 2020, 6:31pm UTC](https://discuss.hashicorp.com/t/how-to-specify-a-port-on-docker-deploy/16520/1 "2020-10-22T18:31:50Z")

</div>

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?

Thanks

---

<div class="post-metadata">

**Author:** ![jbayer](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jbayer/32/2565_2.png) [@jbayer](https://discuss.hashicorp.com/u/jbayer)\
**Post date:** [October 22, 2020, 9:31pm UTC](https://discuss.hashicorp.com/t/how-to-specify-a-port-on-docker-deploy/16520/2 "2020-10-22T21:31:45Z")

</div>

Based on the [reviewing the Docker Platform plugin code](https://github.com/hashicorp/waypoint/blob/main/builtin/docker/platform.go#L167), 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?

---

<div class="post-metadata">

**Author:** ![fernandezpablo85](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/fernandezpablo85/32/13776_2.png) [@fernandezpablo85](https://discuss.hashicorp.com/u/fernandezpablo85)\
**Post date:** [October 22, 2020, 11:02pm UTC](https://discuss.hashicorp.com/t/how-to-specify-a-port-on-docker-deploy/16520/3 "2020-10-22T23:02:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jbayer](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jbayer/32/2565_2.png) [@jbayer](https://discuss.hashicorp.com/u/jbayer)\
**Post date:** [October 23, 2020, 12:51am UTC](https://discuss.hashicorp.com/t/how-to-specify-a-port-on-docker-deploy/16520/4 "2020-10-23T00:51:42Z")

</div>

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](https://github.com/hashicorp/waypoint-examples/tree/main/kubernetes/exec-kubectl-apply) 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.

---

<div class="post-metadata">

**Author:** ![fernandezpablo85](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/fernandezpablo85/32/13776_2.png) [@fernandezpablo85](https://discuss.hashicorp.com/u/fernandezpablo85)\
**Post date:** [October 25, 2020, 6:10pm UTC](https://discuss.hashicorp.com/t/how-to-specify-a-port-on-docker-deploy/16520/5 "2020-10-25T18:10:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jbayer](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jbayer/32/2565_2.png) [@jbayer](https://discuss.hashicorp.com/u/jbayer)\
**Post date:** [October 25, 2020, 10:20pm UTC](https://discuss.hashicorp.com/t/how-to-specify-a-port-on-docker-deploy/16520/6 "2020-10-25T22:20:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mmonti](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/mmonti/32/14663_2.png) [@mmonti](https://discuss.hashicorp.com/u/mmonti)\
**Post date:** [November 13, 2020, 4:25pm UTC](https://discuss.hashicorp.com/t/how-to-specify-a-port-on-docker-deploy/16520/7 "2020-11-13T16:25:03Z")

</div>

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