#Exposing Ports

1 messages · Page 1 of 1 (latest)

river yacht
#

Hi All,
How do we expose ports using dagger, i've not been able to find any docs for this, if someone can guide me that would be great

hidden pewter
#

If you describe your use case here, maybe we can find a workaround.

river yacht
#

@hidden pewter my use case is very simple, i'm just trying to replicate the behaviour that we have with EXPOSE instruction in a Dockerfile, basically, when building my container images using dagger i want to have the resulting image such that the container runtime expose x ports.

digital basin
#

@river yacht EXPOSE in Dockerfiles is mostly for documentation purposes, it doesn't actually have any effects when the container is started since you still need to send the -p flag regardless. Having said that, you might want to follow this discussion as well https://discord.com/channels/707636530424053791/1042501877906022481 since that's related. cc @proper dirge

river yacht
#

Thanks @digital basin

vital locust
#

Thanks, that was useful for my usecase too.

heavy grotto
#

I think you can either :

  1. just skip expose, since tools en generally don’t use it nowadays.

  2. try a hack like this:


justExpose := c.Container().Build(c.Directory().WithNewFile("Dockerfile", "FROM scratch\nEXPOSE 8080"))
ctr := justExpose.<the rest of your build here>
river yacht
#

Thanks @heavy grotto