5

I came across the following Dockerfile.

FROM registry

# I am not clear what this is.
# I do not understand the following comment either.
# tree is helpful to peruse filesystem storage of images
RUN apk add --no-cache tree

For apk add I got the following three so links.

  1. How can I install Docker inside an alpine container?
  2. Running "apk add" command in a docker container with arguments [closed]
  3. rhat8 equivalent of "apk add --no-cache gcc musl-dev linux-headers"

This answer from the first link says "running docker inside alpine"

Can somebody enlighten me please. Why do we want to run docker inside a docker container?

What is this apk add?

VivekDev
  • 20,868
  • 27
  • 132
  • 202
  • 1
    Valid question. I don't understand the downvotes. This Q&A helped me to realize that apk is the default package manager for alpine linux which is used heavily in docker base layers. – Stephan Schielke Dec 07 '21 at 10:55
  • 1
    Feel free to mark the question as accepted – eja Mar 16 '22 at 14:25

1 Answers1

12

apk is the package manager used in alpine. The command installs the tree package in the image.

Additionally the --no-cache flag, doesn't add anything to cache, so you wouldn't need to run rm /var/cache/apk/* later (which is a good practice)

eja
  • 4,677
  • 3
  • 21
  • 30
Henry
  • 42,982
  • 7
  • 68
  • 84