0

All.

I have one question about Docker Layer images.

I think that RUN, ADD, COPY, CMD commands generate a new layer. However, I wonder why CMD command generates a new layer.

For example, I understand that "ADD hoge.txt /var/tmp" requires a layer because the command generates a new file "hoge.txt".However, the command "/bin/bash" generates nothing.

Would you tell me the reason?

In addition, it seems that the command "CMD ["/bin/bash"]" in centos7 Official Image generates a layer including some files as described below.

├── dev
│   ├── console
│   ├── pts
│   └── shm
└── etc
    ├── hostname
    ├── hosts
    ├── mtab -> /proc/mounts
    └── resolv.conf
  • `/bin/bash` *can* change the state. How is Docker supposed to know which commands will or won't modify disk? The only way it could safely run a command without creating a new layer is to make all filesystems read-only when running that command (or make changes to go a temporary layer it throws away). And a lot of things you might want to run with bash _won't work_ if the disk is read-only. – Charles Duffy Jul 29 '20 at 01:03
  • Beyond that, Stack Overflow is only for questions about writing code (and specifically, questions whose answers change the way you go about the practice of writing code, and *not* questions that are matters of curiosity; [What is the rationale for closing "why" questions on language design?](https://meta.stackexchange.com/questions/170394) applies to other "why" questions in general, when the answer isn't expected to tell you how to fix a problem you actually face -- see the "based on actual problems you face" language in https://stackoverflow.com/help/dont-ask). – Charles Duffy Jul 29 '20 at 01:04

0 Answers0