Skip to content

Commit 4c40c0c

Browse files
author
Jakub Lenner
committed
added section, about inline config in compose.yaml for the Portainer, to the 'Custom configs for containers' manual page
1 parent b5c2bf7 commit 4c40c0c

1 file changed

Lines changed: 40 additions & 5 deletions

File tree

docs/10-prerequisities/30-docker/60-custom-configs.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: Custom configs for containers
66

77
# Custom configs for containers
88

9-
## Problem definition
9+
### Problem definition
1010

1111
A users has a **docker image** from which his software can be started.
1212
The image contains pre-compiled binaries with a **default configuration**.
@@ -18,17 +18,19 @@ Configuration can be facilited by several mechanisms:
1818
* shell scripts,
1919
* additional files loaded in runtime.
2020

21-
These **custom configuration files**, which are handed to the software in runtime, need to be exposed to the **container** runing from the **user's docker image**.
21+
There are two ways how to provide **custom configuration files** to the system:
22+
1. expose them to the **container** runing from the **user's docker image**
23+
2. paste them as a part of the **compose.yaml** file directly from the Portainer
2224

23-
## Our solution
25+
## Solution 1. - Through docker image
2426

2527
We pack the configurations (**shared data**) in a dedicated transport image which is easily delivered to the robot.
2628
Then, **during runtime**, this image spawns a container in which the data is coppied to a **shared docker volume**.
2729
Then, the user's containers are started, all mounting the same **shared docker volume** and accessing the configuration data.
2830

2931
![](./fig/containers_shared_data.png)
3032

31-
## Packing shared data to a transport image
33+
### Packing shared data to a transport image
3234

3335
The following minimalistic dockerfile coppies the `shared_data` subfolder in the **transport docker image**:
3436

@@ -47,7 +49,7 @@ Select the appropriate `tag` and `platform`.
4749
docker build build . --file Dockerfile --tag <shared_data_image_tag> --platform=linux/<my_platform>
4850
```
4951

50-
## Unloading the shared data from the transport image
52+
### Unloading the shared data from the transport image
5153

5254
The following compose session shows the process of unloading the shared data.
5355
The `user_program` can then access the files in the shared docker volume.
@@ -75,3 +77,36 @@ services:
7577
- shared_data:/etc/docker/shared_data:consistent
7678
command: my_process /etc/docker/shared_data/config_file.txt
7779
```
80+
## Solution 2. - Inline, through compose.yaml from Portainer
81+
82+
When you are starting the system from the Portainer using Docker Compose, you can past the yaml config directly to the compose.yaml file. Example:
83+
84+
```
85+
services:
86+
realsense:
87+
image: ctumrs/realsense
88+
#build: .
89+
privileged: true
90+
network_mode: "host"
91+
configs:
92+
- source: cfg_yaml
93+
target: /custom_config.yaml
94+
mode: 0444 # read-only permissions
95+
command: custom_config:=/custom_config.yaml
96+
97+
configs:
98+
cfg_yaml:
99+
content: |
100+
/uav1/rgbd:
101+
ros__parameters:
102+
remappings:
103+
'~/depth/image_rect_raw': ~/depth/image_raw
104+
'~/depth/image_rect_raw/compressed': ~/depth/image_raw/compressed
105+
'~/depth/image_rect_raw/compressedDepth': ~/depth/image_raw/compressedDepth
106+
aligned_depth_to_color:
107+
image_raw:
108+
compressed:
109+
format: jpeg
110+
```
111+
112+
This is **compose.yaml** for starting Docker container for the Realsense camera. Configuration in the yaml format is under the **configs** section, in the **content** subsection. This content is copied into the file specified in the service section, in the configs/target subsections - **/custom_config.yaml**. It is then passed to the ROS2 launchfile through **command** subsection. The user only needs to modify the **configs** section.

0 commit comments

Comments
 (0)