rhit-neuro / parallel-neuro-simulation

3 stars 2 forks source link

Clean apt cache after apt update in Dockerfile #10

Closed heidecjj closed 5 years ago

heidecjj commented 5 years ago

In GitLab by @zhouz2 on Feb 26, 2018, 11:08

According to this article, each RUN command adds a new layer, and layer creation has a copy-on-write policy that would only result in size increases. Therefore, to decrease the size of an image, one should clean up files in the same RUN command as the command that adds the files. In our case, we run apt update without cleaning its cache afterward. We should do that.

heidecjj commented 5 years ago

In GitLab by @zhouz2 on Mar 10, 2018, 21:08

assigned to @heidecjj

heidecjj commented 5 years ago

In GitLab by @heidecjj on Mar 11, 2018, 15:35

@zhouz2 I'm not 100% sure what is meant by official, but are we using an official Ubuntu image? If so, apt-get clean is run automatically. Docker's site says "Note: The official Debian and Ubuntu images automatically run apt-get clean, so explicit invocation is not required." Here's a link to where I found that: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run

heidecjj commented 5 years ago

In GitLab by @zhouz2 on Mar 11, 2018, 16:09

@heidecjj Nice find, but I also saw that right above that text, the sample RUN command has a line of rm -rf /var/lib/apt/lists/*. According to this StackOverflow answer, this folder is not cleaned by apt clean. I think we should include this command rather than apt clean.

heidecjj commented 5 years ago

In GitLab by @heidecjj on Mar 11, 2018, 19:50

Looks like it worked. Here's the output of docker image ls. nsenvtest2 is with the new Dockerfile and nsenvtest is with the old Dockerfile.

REPOSITORY                              TAG                 IMAGE ID            CREATED             SIZE
nsenvtest2                              latest              e4f54782097b        26 seconds ago      1.07GB
nsenvtest                               latest              a37d28875cbd        4 hours ago         1.11GB
heidecjj commented 5 years ago

In GitLab by @heidecjj on Mar 11, 2018, 19:51

created branch 10-clean-apt-cache-after-apt-update-in-dockerfile

heidecjj commented 5 years ago

In GitLab by @heidecjj on Mar 11, 2018, 19:51

mentioned in merge request !5

heidecjj commented 5 years ago

In GitLab by @zhouz2 on Mar 12, 2018, 11:57

closed via commit 1574a536b9147386ccf914151e6dd6c6c7f7e64c

heidecjj commented 5 years ago

In GitLab by @zhouz2 on Mar 12, 2018, 11:57

closed via merge request !5

heidecjj commented 5 years ago

In GitLab by @zhouz2 on Mar 13, 2018, 15:06

mentioned in commit 1574a536b9147386ccf914151e6dd6c6c7f7e64c

heidecjj commented 5 years ago

In GitLab by @zhouz2 on Mar 14, 2018, 00:00

unassigned @heidecjj