|
| 1 | +--- |
| 2 | +title: Sidecar Container |
| 3 | +status: Completed |
| 4 | +category: concept |
| 5 | +--- |
| 6 | + |
| 7 | +The Sidecar Container is an implementation of the sidecar pattern. |
| 8 | +An application deployed on a second container will run side by side |
| 9 | +and share its lifecycle with a primary application running on a main container. |
| 10 | + |
| 11 | +## Problem it addresses |
| 12 | + |
| 13 | +There are cross-platform situations where it is convenient to group [containers](/container/) |
| 14 | +and their lifecycle to deal with scenarios |
| 15 | +like logging, monitoring, tracing, but also security, and networking. |
| 16 | +Before this approach, logging would typically be implemented in the application code |
| 17 | +inside the container. |
| 18 | +This can lead to different ways to implement the logic, |
| 19 | +depending on the developer or application, |
| 20 | +normally resulting in more complex systems to maintain and govern. |
| 21 | +For example, updating the logging logic might impact the application in runtime, |
| 22 | +hence increasing operational risk. |
| 23 | + |
| 24 | +## How it helps |
| 25 | + |
| 26 | +It enforces the principle of separation of concerns |
| 27 | +and provides extending functionality without changing the main application's code, |
| 28 | +by using a separated process running on a secondary container. |
| 29 | + |
| 30 | +The sidecar container will share the same resources, |
| 31 | +including storage and networking, as the main container. |
| 32 | +While doing this, it frees the main container to be focused on functional tasks |
| 33 | +or exposing business capabilities. |
| 34 | + |
| 35 | +For example, when multiple microservices have their sidecar containers |
| 36 | +acting as logging agents reading from the same directory, |
| 37 | +the main application is writing its logs to. |
0 commit comments