0

I'm doing some query tests with Impala/HDFS inside docker containers (swarm). In order to compare the queries (different scale factors), I want to drop the cache. Normally this is easily done by

$ sync
$ echo 1 > /proc/sys/vm/drop_caches

but I don't have admin rights on the host system. Is there another way to drop the cache from the inside of the containers? Is it an option to create another big table and execute queries on this table so that its data overwrite the cache?

4
  • how do you enter in the container?
    – Edwin
    Commented Aug 16, 2018 at 11:22
  • Via: docker exec -it <Container_ID> bash Commented Aug 16, 2018 at 11:31
  • have you tried docker exec -it -u0 <Container_ID> bash ?
    – Edwin
    Commented Aug 16, 2018 at 11:36
  • I can enter the container with -u0. But if I execute the latter command from above, I get: bash: /proc/sys/vm/drop_caches: Read-only file system Commented Aug 16, 2018 at 11:40

3 Answers 3

1

You cannot do this from inside the conatiner. The root user in the container is in a different namespace than the actual root, and only the latter has access to /proc.

1
  • Yes, I know that I'm not allowed to execute this command. But what other options do I have (like overwriting the cache)? Commented Aug 16, 2018 at 11:51
0

You could try volume mount in the host proc filesystem into the container. This seems to work for me:

$ docker run -ti --rm -v /proc/sys/vm/drop_caches:/drop_caches alpine
/ # free
             total       used       free     shared    buffers     cached
Mem:       2046644     808236    1238408        688       2248     118244
-/+ buffers/cache:     687744    1358900
Swap:      1048572      31448    1017124
/ # dd if=/dev/zero of=/dummy count=500 bs=1M
500+0 records in
500+0 records out
/ # free
             total       used       free     shared    buffers     cached
Mem:       2046644    1333892     712752        688       2268     630268
-/+ buffers/cache:     701356    1345288
Swap:      1048572      31448    1017124
/ # echo 3 > drop_caches
/ # free
             total       used       free     shared    buffers     cached
Mem:       2046644     790136    1256508        688        764     101552
-/+ buffers/cache:     687820    1358824
Swap:      1048572      31448    1017124
/ #

... but that is assuming you control how the container is started, which would more or less mean you're admin.

0

Can be achieved by starting container in privileged mode using --privileged flag.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.