Skip to content
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

Add 'TAG' and 'COMPRESS' command to Dockerfile #12987

Closed
xuxinkun opened this issue May 5, 2015 · 5 comments
Closed

Add 'TAG' and 'COMPRESS' command to Dockerfile #12987

xuxinkun opened this issue May 5, 2015 · 5 comments
Labels
kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny

Comments

@xuxinkun
Copy link

xuxinkun commented May 5, 2015

TAG command should allow to:

  • Create multiple images from a single Dockerfile
  • Create different tags for the same image

See more info in #5603 commented by @thaJeztah .

I also think it is nessary to add a 'COMPRESS' command. It is more likely to the #332.
It can compress the layers between a parent layer and the last layer.

For example:

FROM centos:latest
RUN yum install -y xxx
MAINTAINER xxx
EXPOSE 80
COMPRESS centos:latest
EXPOSE 8080

Now, we can get the images like this.

└─ad18ff9f83df Virtual Size: 484.7 MB Tags: centos:latest
    └─f45f88e50248 Virtual Size: 552.7 MB
        └─3e5747d65960 Virtual Size: 552.8 MB
            └─8c381ae7a086 Virtual Size: 552.8 MB
    └─13d909f018b8 Virtual Size: 552.8 MB
        └─5701e3b9b9ed Virtual Size: 552.8 MB
  • ad18ff9f83df: FROM centos:latest
  • f45f88e50248: RUN yum install -y xxx
  • 3e5747d65960: MAINTAINER xxx
  • 8c381ae7a086: EXPOSE 80
  • 13d909f018b8: COMPRESS centos:latest
  • 5701e3b9b9ed: EXPOSE 8080

As we see, 'COMPRESS' command can compress the layers between 'ad18ff9f83df' and '8c381ae7a086', and build a new layer '13d909f018b8' which contains all the content of 'f45f88e50248', '3e5747d65960' and '8c381ae7a086'. Besides, the new layer '13d909f018b8' will be the child of 'centos:latest'. The command after it will be based on this image layer.

By this two command, we will have some interesting method to organise the Dockerfile.

For example:

FROM centos:latest
RUN yum install -y xxx
MAINTAINER xxx
EXPOSE 80    
COMPRESS centos:latest
TAG mytest:base
EXPOSE 8080
TAG mytest:v1
RUN yum install -y xxx
COMPRESS mytest:base
TAG mytest:v2

We can get images below.

└─ad18ff9f83df Virtual Size: 484.7 MB Tags: centos:latest
    └─f45f88e50248 Virtual Size: 552.7 MB
        └─3e5747d65960 Virtual Size: 552.8 MB
            └─8c381ae7a086 Virtual Size: 552.8 MB
    └─13d909f018b8 Virtual Size: 552.8 MB Tags: mytest:base
        └─5701e3b9b9ed Virtual Size: 552.9 MB Tags: mytest:v1
            └─33c38b267b5e Virtual Size: 553.9 MB
                └─e7da47ddcdf7 Virtual Size: 553.9 MB
        └─98354e5ca627 Virtual Size: 553.9 MB Tags: mytest:v2
  • ad18ff9f83df: FROM centos:latest
  • f45f88e50248: RUN yum install -y xxx
  • 3e5747d65960: MAINTAINER xxx
  • 8c381ae7a086: EXPOSE 80
  • 13d909f018b8: COMPRESS centos:latest
  • 13d909f018b8: TAG mytest:base
  • 5701e3b9b9ed: EXPOSE 8080
  • 5701e3b9b9ed: TAG mytest:v1
  • 33c38b267b5e: RUN yum install -y xxx
  • e7da47ddcdf7:EXPOSE 8090
  • 98354e5ca627:COMPRESS mytest:base
  • 98354e5ca627:TAG mytest:v2

As we see, this is very useful for the iterative development.

TAG command has been written and tested. I make a pull request, see #12983 .

COMPRESS command has also been written but not already tested. I will take the opinions of the community and then make another pull request.

@thaJeztah
Copy link
Member

This looks like a duplicate of #332 (or #6906), there's currently a work in progress PR for a MARK...SQUASH feature (which is basically what you're describing here) in #12198

@thaJeztah thaJeztah added kind/proposal kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny labels May 5, 2015
@jdmarshall
Copy link

I think there's a softer version of this that could be distinct from and implemented separately from #332

If you could tag layers like you can tag images, then being able to tell Docker "Hey, can you rerun this Dockerfile and recalculate all of the layers after LayerX, that would be super"

When I update an external file that gets pulled into the middle of my build I'd love a shorthand form of being able to rerun the second half without refetching 100MB of packages, which is what happens if I use --no-cache.

@thaJeztah
Copy link
Member

@jdmarshall that sounds more like #10682

@jdmarshall
Copy link

@thaJeztah Interesting way to achieve the task, but I'm going to file a request that meets my need without changing the Dockerfile: #12998

@tiborvass
Copy link
Contributor

This is an exotic duplicate of both #5603 and #12198

I'm closing this since both of those issues have been closed with explanations.

Feel free to object if you think this is different from those other ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny
Projects
None yet
Development

No branches or pull requests

4 participants