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

Docker images layers not optimal #481

Closed
Oleksii-Terekhov opened this issue Jan 9, 2019 · 3 comments
Closed

Docker images layers not optimal #481

Oleksii-Terekhov opened this issue Jan 9, 2019 · 3 comments
Labels
area/build-tools Development tooling. I.e. pretty much everything in the `build` directory.
Milestone

Comments

@Oleksii-Terekhov
Copy link

When I pull/push gcr.io/agones-images/agones-sdk:0.7.0 and gcr.io/agones-images/agones-controller:0.7.0 to private registry, I notice strange layers sizes. After digging in docker history --no-trunc i discover:

$ docker history gcr.io/agones-images/agones-sdk:0.7.0 --no-trunc
SIZE       CREATED BY                                                                                                                 
           ...
36.3MB     /bin/sh -c chown -R agones /home/agones &&     chmod o+x /home/agones/sdk-server                                           
36.3MB     /bin/sh -c #(nop) COPY file:8722bd89cce1b48c82a0c1fd092dc023d376a017c441e11339f5febcb59db882 in /home/agones/sdk-server    
           ...
           
           $ docker history gcr.io/agones-images/agones-controller:0.7.0 --no-trunc
SIZE       CREATED BY                                                                                                                 
           ...
38.1MB     /bin/sh -c chown -R agones /home/agones &&     chmod o+x /home/agones/controller                                           
38.1MB     /bin/sh -c #(nop) COPY file:d96d94ca03fbe2e312ab882c2cf14cee205dad4720f27dc5c1a567cdc6307899 in /home/agones/controller    
...

All binary layers doubled :(

Maybe use COPY --chown=user:group src... dest and fix execution flag via Makefile?

Same thing with gcr.io/agones-images/agones-ping:0.7.0

@cyriltovena
Copy link
Collaborator

I'll have a look at this.

@aLekSer
Copy link
Collaborator

aLekSer commented Jan 9, 2019

Actually we can reduce the size of containers twice (same applies to agones-controller image 44.5 vs 82.8 MB):

docker image ls | grep ping 
gcr.io/agones-alexander/agones-ping            0.8.0-86b1326       c0044f50ca15        22 minutes ago      18.9MB
gcr.io/agones-images/agones-ping               0.8.0-86b1326       b66ae871dcec        About an hour ago   31.6MB

I have performed a test with COPY --chmod parameter in Dockerfile and without:
The resulting permissions are the same so it seems that chmod o+x is redundant.
With following lines in Ping Dockerfile:

COPY --chown=agones:root ./bin/ping /home/agones/ping

USER agones

RUN ls -al /home/agones

I got such output:

Step 5/6 : RUN ls -al /home/agones
 ---> Running in 37df117b94c0                                                                                                                                                                            
total 12404
drwxr-sr-x    1 agones   agones        4096 Jan  9 13:06 .
drwxr-xr-x    1 root     root          4096 Dec  4 08:46 ..
-rwxr-xr-x    1 agones   root      12692425 Jan  9 13:06 ping

I got same permissions to a file and directory as when I run current version of Docker image:

docker run --name ping -d gcr.io/agones-images/agones-ping:0.8.0-86b1326  
docker exec -it ping /bin/sh
/ $ ls -al /home/agones
total 12408
drwxr-sr-x    1 agones   agones        4096 Jan  9 12:52 .
drwxr-xr-x    1 root     root          4096 Dec  4 08:46 ..
-rwxr-xr-x    1 agones   root      12692425 Jan  9 12:39 ping

Not sure would the resulting Dockerfile be cross-platform or not.

@cyriltovena
Copy link
Collaborator

yep getting the same result on macos, I'm pushing a PR.

@markmandel markmandel added this to the 0.8.0 milestone Feb 5, 2019
@markmandel markmandel added the area/build-tools Development tooling. I.e. pretty much everything in the `build` directory. label Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build-tools Development tooling. I.e. pretty much everything in the `build` directory.
Projects
None yet
Development

No branches or pull requests

4 participants