repo2docker
repo2docker copied to clipboard
Emit an EXPOSE entry for ports specified in -p to repo2docker
Primarily as documentation in the built image rather than anything particularly useful for repo2docker itself. However, we have to remember that ports are really a runtime parameter, and make sure we think about caching issues with adding an EXPOSE.
Split from https://github.com/jupyter/repo2docker/issues/533#issuecomment-451689268
A separate --expose command or something similar seems ok to me - primarily from the perspective of separating build time parameters from run time ones. But want to make sure we do the least surprising and 'right' thing by default
I like the idea of recording the information.
Could we maybe use a LABEL instead of/in addition to an EXPOSE so that we can record more information, namely the host port to which to map the exposed port?
docker run also has -P(--publish-all , -P Publish all exposed ports to random ports).
I'd vote for using EXPOSE (somewhere at the end of the Dockerfile where the labels are) to record the container port that the user running repo2docker to build the image specified (repo2docker -p 1234:4321 puts EXPOSE 4321 in the file (or the other way around, which ever is the port inside the container).
This means that when someone then docker runs that image they are in the same position they'd be in when running an image built by (say) docker build. There must be a reason why Docker makes users explicitly choose which port to expose things on on the host and when asked to automate this (-P) chooses random ports.
Is this still something we'd like to add?