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

Remove apk cache #229

Closed
wants to merge 1 commit into from
Closed

Conversation

mtsmfm
Copy link
Contributor

@mtsmfm mtsmfm commented Sep 6, 2018

$ docker image ls ruby:alpine
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ruby                alpine              e8e61f5c55cb        35 hours ago        62MB

$ docker run --rm -it ruby:alpine ls -la /var/cache/apk
total 1204
drwxr-xr-x    1 root     root          4096 Sep  5 05:55 .
drwxr-xr-x    1 root     root          4096 Jul  5 14:46 ..
-rw-r--r--    1 root     root        451901 Sep  5 05:55 APKINDEX.5022a8a2.tar.gz
-rw-r--r--    1 root     root        769090 Sep  5 05:55 APKINDEX.70c88391.tar.gz
$ docker image ls my-ruby
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
my-ruby             latest              ca40c914bcb6        About a minute ago   60.8MB

$ docker run --rm -it my-ruby ls -la /var/cache/apk
total 8
drwxr-xr-x    2 root     root          4096 Jul  5 14:46 .
drwxr-xr-x    1 root     root          4096 Jul  5 14:46 ..

```
$ docker image ls ruby:alpine
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ruby                alpine              e8e61f5c55cb        35 hours ago        62MB

$ docker run --rm -it ruby:alpine ls -la /var/cache/apk
total 1204
drwxr-xr-x    1 root     root          4096 Sep  5 05:55 .
drwxr-xr-x    1 root     root          4096 Jul  5 14:46 ..
-rw-r--r--    1 root     root        451901 Sep  5 05:55 APKINDEX.5022a8a2.tar.gz
-rw-r--r--    1 root     root        769090 Sep  5 05:55 APKINDEX.70c88391.tar.gz
```

```
$ docker image ls my-ruby
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
my-ruby             latest              ca40c914bcb6        About a minute ago   60.8MB

$ docker run --rm -it my-ruby ls -la /var/cache/apk
total 8
drwxr-xr-x    2 root     root          4096 Jul  5 14:46 .
drwxr-xr-x    1 root     root          4096 Jul  5 14:46 ..
```
bzip2 \
ca-certificates \
libffi-dev \
libressl-dev \
procps \
yaml-dev \
zlib-dev \
&& apk del .ruby-builddeps \
&& apk del --no-cache .ruby-builddeps \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From docker-library/python#330 (comment):

This is actually a (recent) bug, and they're planning to fix it: https://bugs.alpinelinux.org/issues/9063

(https://git.alpinelinux.org/cgit/apk-tools/commit/?id=e1a05c74cb8ae6ab41ee960343cc64a0a9af95a5)

https://git.alpinelinux.org/cgit/apk-tools/commit/?id=8a28c6d0d4f81406c67e76b2bcdbe491aa734717 appears to be the commit which introduced this "autoupdate" behavior.

On the other hand, it does affect alpine 3.7 based images (and current 3.8) since the Alpine bug is only being updated in 3.8. 😢

Now every apk add|del will need to download the cache and delete it, even if it could've been done without hitting the network (and --no-network doesn't help).

So, I guess LGTM cc @tianon.

@yosifkit
Copy link
Member

yosifkit commented Sep 6, 2018

cc @ncopa, is there any other way to get apk to not download the cache on every add/del?

This bug, https://bugs.alpinelinux.org/issues/9063, shows that only 3.8 is getting the fix for del, could that be backported to 3.7 as well or is that outside of what can be backported?

I'm not sure if you have seen an increase in bandwidth on your cdn, but this issue could have a large impact as we fix base images to not have cache files and every user starts downloading them in each del and add. It was nice it 3.6 when we could add a --virtual package without pulling down cache.

Related issues: docker-library/python#330, docker-library/php#708

@ncopa
Copy link
Contributor

ncopa commented Sep 7, 2018

I guess it makes sense to fix it in v3.7 as well.

algitbot pushed a commit to alpinelinux/aports that referenced this pull request Sep 7, 2018
prevent update repository index when --no-network is specified.
fixes #9126

Backported on request:
docker-library/ruby#229 (comment)
@tianon
Copy link
Member

tianon commented Sep 7, 2018

So if I'm reading right, we should be using --no-network on apk add --virtual ... (things that are already installed) and apk del? 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants