Vulkan: What is the meaning of 'attachment'
To understand attachments in Vulkan, You first need to understand render-passes and sub-passes.
Render-pass is a general description of steps Your drawing commands are divided into and of resources used during rendering. We can't render anything in Vulkan without a render pass. And each render pass must have one or more steps. These steps are called,
Sub-passes and each sub-pass uses a (sub)collection of resources defined for the render-pass. Render-pass's resources may include render-targets (color, depth/stencil, resolve) and input data (resources that, potentially, were render-targets in previous sub-passes of the same render-pass). And these resources are called,
Attachments (they don't include descriptors/textures/samplers and buffers).
Why don't we call them just render-targets or images? Because we not only render into them (input attachments) and because they are only descriptions (meta data). Images that should be used as attachments inside render-passes are provided through framebuffers.
So, in general, we can call them images, because (as far as I know) only images can be used for attachments. But if we want to be fully correct: images are specific Vulkan resources that can be used for many purposes (descriptors/textures, attachments, staging resources); attachments are descriptions of resources used during rendering.
There is actually several type of attachments. I will explain the two most common.
Color / Depth Attachment
These are images you are written into it. As Zebrafish told, it allows you to draw something (via vkCmdDraw*) into them. You can after read them. They are one output.
Input Attachment :
These, as the name told are used as input and not as an output. For example, let's say you are building a deferred renderer, you will have several subpasses (2 to be simple).
Your first subpass will write into several images (your G_BUFFER) : albedo / normal / depth.
Once you have finish this subpass, you can begin another one (the lighting one) and to make lighting computation, you need to give this pass some inputs (your G-Buffer). You set your G-Buffer images as an input attachment.
What is the difference between input attachment and "sampler" ? Input Attachment are not adressable, and you can get only the pixel you are working on. It probably allows driver to make some optimization, and could be used as a transient attachment to optimize rendering using Tiled GPU (but that is another question).