Skip to content

Commit

Permalink
+ docker custom configs
Browse files Browse the repository at this point in the history
  • Loading branch information
klaxalk committed Dec 4, 2024
1 parent 7722bb0 commit a7f94b2
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
70 changes: 69 additions & 1 deletion docs/10-prerequisities/30-docker/60-custom-configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,72 @@ description: Custom configs for containers

# Custom configs for containers

TODO
## Problem definition

A users has a **docker image** from which his software can be started.
The image contains pre-compiled binaries with a **default configuration**.
However, in many cases (robotics applications), the user's software needs to be started with **different configuration** each time.
Configuration can be facilited by several mechanisms:

* config files,
* ROS launch files,
* shell scripts,
* additional files loaded in runtime.

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**.

## Our solution

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

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

## Packing shared data to a transport image

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

```dockerfile
FROM alpine

COPY shared_data/ /etc/docker/shared_data/

CMD ["sh"]
```

Build the image using the following command.
Select the appropriate `tag` and `platform`.

```bash
docker build build . --file Dockerfile --tag <shared_data_image_tag> --platform=linux/<my_platform>
```

## Unloading the shared data from the transport image

The following compose session shows the process of unloading the shared data.
The `user_program` can then access the files in the shared docker volume.

```yaml
volumes:

shared_data:

services:

# will copy session-specific data shared between containers from the shared_data container to a shared volume
copy_shared_data:
image: <shared_data_image_tag>
volumes:
- shared_data:/tmp/docker/shared_data:consistent
tty: true
command: sh -c "rm -rvf /tmp/docker/shared_data/*; mkdir -pv /tmp/docker/shared_data; cp -rv /etc/docker/shared_data/* /tmp/docker/shared_data/"

user_program:
image: <users_base_image>
depends_on:
- copy_shared_data
volumes:
- shared_data:/etc/docker/shared_data:consistent
command: my_process /etc/docker/shared_data/config_file.txt
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a7f94b2

Please sign in to comment.