-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Propagate container configuration from base image? #595
Comments
Hmm... if the images built by docker in the normal way don't inherit the container configuration, I think we don't need to do this. OTOH, if they do, this is something we can consider. |
Yes, I believe Dockerfile |
This is useful for me to pick up on the Env from a base image (specifically |
Without this feature we will be forced to copy/link the java executables into the /usr/bin directory which might not be desirable. |
I think for this feature, we can start with propagating environment variables since that seems to be the most useful case. |
Adjusting the milestone since we were only planning on propagating environment variables for this next release. |
For those who are following this issue, environment variables from the base image are now being propagated into the target image, starting from Jib 0.9.8. |
Turns out we also need to propagate |
Also However, this is a bit different: we have a config parameter for setting the value. The question becomes then, should we add ports on top of the ports from the base image? Or, does it still make sense to replace the base value with the value given by our config parameter? Maybe, we inherit ports only when not configured in Jib, but when configured, just replace the ports from the base? |
#924: |
@chanseokoh I like using the base image ports if none is specified. Also, I think volumes must be inherited as well. After the PR for supporting volume configuration (#1215) is accepted we can do it. |
@GuustavoPaiva yeah, we actually do need to inherit the ports and the volumes, which docker does with |
We have two left: volumes and healthcheck Updated original post with a TODO list. |
I think we haven't handled ports either. Updated the TODO list. |
Also need to check if UPDATE(04/23/2020): issue #2421 reported. |
Just in case, I am documenting here that there is one subtle to be careful about when enabling inheriting ports, volumes, etc. In // inherit properties
imageBuilder
.addEnvironment(baseImage.getEnvironment())
.addLabels(baseImage.getLabels())
.setWorkingDirectory(baseImage.getWorkingDirectory());
...
// set properties when explicitly given
if (containerConfiguration != null) {
imageBuilder
.addEnvironment(containerConfiguration.getEnvironmentMap())
...
.setExposedPorts(containerConfiguration.getExposedPorts())
.setVolumes(containerConfiguration.getVolumes())
...
} To inherit volumes for example, one would start with // inherit properties
imageBuilder
...
.setWorkingDirectory(baseImage.getWorkingDirectory())
.setVolumes(baseImage.getVolumes()); // inherit volumes, YEAH!
...
// set properties when explicitly given
if (containerConfiguration != null) {
...
} In addition to this, we should update the code to selectively override properties: // inherit properties
imageBuilder
...
.setVolumes(baseImage.getVolumes()); // inherit volumes, YEAH!
// set properties when explicitly given
if (containerConfiguration != null) {
...
// should override only when actually given
if (containerConfiguration.getExposedPorts() != null) {
imageBuilder.setExposedPorts(containerConfiguration.getExposedPorts());
}
// should override only when actually given
if (containerConfiguration.getVolumes() != null) {
imageBuilder.setVolumes(containerConfiguration.getVolumes());
}
} UPDATE: we should actually do |
I think we should be adding the volumes/ports rather than replacing them since that's the behavior of Dockerfile builds as well. So, having port |
Ah, you're right. We should actually do |
When generating the container configuration, there would be no duplicates since the ports/volumes are maps to empty objects. We should probably just have them be represented as sets instead of lists in the image builder and other parts of the API too though. |
@essh @cwensel @thekguy @sunnychanwork @joelhandwell @jcrossley3 @Tanmayshetty All of these configurations are propagated from the base image now in version |
Thumbs up if this is useful for you.
Configuration currently propagated from the base image:
UPDATE(04/23/2020):
The text was updated successfully, but these errors were encountered: