diff --git a/docs/10-prerequisities/30-docker/60-airgapped-machines.md b/docs/10-prerequisities/30-docker/60-airgapped-machines.md deleted file mode 100644 index f88ede09..00000000 --- a/docs/10-prerequisities/30-docker/60-airgapped-machines.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: Airgapped machines -pagination_label: Working with airgapped machines -description: How to work with airgapped machines ---- - -# Airgapped machines with Docker diff --git a/docs/10-prerequisities/30-docker/60-offline-machines.md b/docs/10-prerequisities/30-docker/60-offline-machines.md new file mode 100644 index 00000000..29d87c19 --- /dev/null +++ b/docs/10-prerequisities/30-docker/60-offline-machines.md @@ -0,0 +1,7 @@ +--- +title: Offline machines +pagination_label: Working with offline machines +description: How to work with offline machines +--- + +# Offline machines with Docker diff --git a/docs/10-prerequisities/32-portainer.md b/docs/10-prerequisities/32-portainer.md deleted file mode 100644 index 1dee8bc5..00000000 --- a/docs/10-prerequisities/32-portainer.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: Portainer.io -pagination_label: Deploying Docker with Portainer.io -description: Deploying Docker with Portainer.io ---- - -# Portainer.io diff --git a/docs/10-prerequisities/32-portainer/01-starting.md b/docs/10-prerequisities/32-portainer/01-starting.md new file mode 100644 index 00000000..bdc6f80e --- /dev/null +++ b/docs/10-prerequisities/32-portainer/01-starting.md @@ -0,0 +1,126 @@ +--- +title: Starting Portainer +pagination_label: Starting Portainer +description: Starting Portainer +--- + +# Starting Portainer + +Portainer can be started using a simple compose session. +By default, the containers will respawn when the computer restarts. + +## Portainer Agent + +The Portainer Agent is responsible for communicating with the local docker daemon. + +
+Compose file + +```yaml +services: + + portainer_agent: + + image: portainer/agent:2.21.0 + + ports: + - 9001:9001 + + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - /var/lib/docker/volumes:/var/lib/docker/volumes + - /:/host + + restart: always +``` + +
+ +## Portainer Server + +The Portainer Server is what creates the Web UI. +A single server can be connected to more than one **agent**. + +
+Compose file + +```yaml +volumes: + + portainer_data: + +services: + + portainer: + + image: portainer/portainer-ce:2.21.0 + + ports: + - 8000:8000 + - 9000:9000 + - 9443:9443 + + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - portainer_data:/data + + restart: always + + command: --http-enabled +``` + +
+ +## Both the Agent and the Server on a single machine + +In case of a single robot, we might run both on a single machine. +In that case, a single session for both will suffice. + +
+Compose file + +```yaml +volumes: + + portainer_data: + +services: + + portainer_agent: + + image: portainer/agent:2.21.2 + + network_mode: host + + ports: + - 9001:9001 + + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - /var/lib/docker/volumes:/var/lib/docker/volumes + - /:/host + + restart: always + + portainer: + + image: portainer/portainer-ce:2.21.2 + + network_mode: host + + ports: + - 8000:8000 + - 9000:9000 + - 9443:9443 + + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - portainer_data:/data + + restart: always + + command: --http-enabled + +``` + +
diff --git a/docs/10-prerequisities/32-portainer/10-connecting-to.md b/docs/10-prerequisities/32-portainer/10-connecting-to.md new file mode 100644 index 00000000..11a3f62d --- /dev/null +++ b/docs/10-prerequisities/32-portainer/10-connecting-to.md @@ -0,0 +1,13 @@ +--- +title: Connecting to Portainer +pagination_label: Connecting to Portainer +description: Connecting to Portainer +--- + +# Connecting to portainer + +1. Open your web browser +2. Determine the hostname of the machine that run Portainer (e.g., `localhost`, or `uav1`) +3. Open the url [https://localhost:9443](https://localhost:9443) (substitude your hostname) + +![](./fig/portainer_login.png) diff --git a/docs/10-prerequisities/32-portainer/50-example-stacks.md b/docs/10-prerequisities/32-portainer/50-example-stacks.md new file mode 100644 index 00000000..e78747a5 --- /dev/null +++ b/docs/10-prerequisities/32-portainer/50-example-stacks.md @@ -0,0 +1,371 @@ +--- +title: Example stacks +pagination_label: Example Portainer stacks (compose sessions) +description: Example Portainer stacks (compose sessions) +--- + +# Example stacks + +Stacks are **docker compose sessions** within portainer. +As in vanilla docker, stacks are defined by a [compose file](/docs/prerequisities/docker/compose-sessions). +Moreover, a set of environment varibles is defined _by hand_ in Portainer, which can define how the session behave. + +## Example simulation session + +An example simulation session is located at [mrs_docker/tree/master/compose/1.5.0/portainer](https://github.com/ctu-mrs/mrs_docker/tree/master/compose/1.5.0/portainer). +Custom configs for the MRS UAV System are supposed to be packed into a transport docker image. +The subfolder `custom_configs` containes the example custom cofigs and scripts for build an image that is going to unload the configs during the runtime for the running containers. + +
+Compose file + +```yaml +volumes: + + shared_data: + + bag_files: + + logs: + +services: + + # will copy session-specific data shared between containers from the shared_data container to a shared volume + copy_shared_data: + image: ctumrs/gazebo_simulator:shared_data + 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/" + + roscore: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + network_mode: host + depends_on: + - copy_shared_data + env_file: + - ./stack.env + tty: true + command: roscore + + gazebo_simulator: + depends_on: + - roscore + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + network_mode: host + volumes: + - shared_data:/etc/docker/shared_data:consistent + # mount the folders below to enable passing GUI to the host + - /dev/dri:/dev/dri + - /tmp/.X11-unix:/tmp/.X11-unix + env_file: + - ./stack.env + environment: + DISPLAY: $DISPLAY + tty: true + command: bash -c "waitForRos && roslaunch mrs_uav_gazebo_simulation simulation.launch world_name:=grass_plane gui:=true" + + spawn: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + depends_on: + - roscore + network_mode: host + volumes: + - shared_data:/etc/docker/shared_data:consistent + env_file: + - ./stack.env + tty: true + command: bash -c 'waitForGazebo; rosservice call /mrs_drone_spawner/spawn "1 --$$UAV_TYPE --enable-rangefinder"' + + hw_api: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + depends_on: + - roscore + network_mode: host + volumes: + - shared_data:/etc/docker/shared_data:consistent + env_file: + - ./stack.env + tty: true + command: bash -c "waitForTime && roslaunch mrs_uav_px4_api api.launch" + + uav_core: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + depends_on: + - roscore + network_mode: host + volumes: + - shared_data:/etc/docker/shared_data:consistent + env_file: + - ./stack.env + tty: true + command: bash -c "waitForHw && roslaunch mrs_uav_core core.launch platform_config:=`rospack find mrs_uav_gazebo_simulation`/config/mrs_uav_system/$$UAV_TYPE.yaml custom_config:=/etc/docker/shared_data/custom_config.yaml world_config:=/etc/docker/shared_data/world_config.yaml network_config:=/etc/docker/shared_data/network_config.yaml" + + automatic_start: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + depends_on: + - roscore + network_mode: host + volumes: + - shared_data:/etc/docker/shared_data:consistent + env_file: + - ./stack.env + tty: true + command: bash -c "waitForHw && roslaunch mrs_uav_autostart automatic_start.launch custom_config:=/etc/docker/shared_data/automatic_start.yaml" + + # starts `rosbag record` + rosbag: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + depends_on: + - roscore + network_mode: host + volumes: + - bag_files:/etc/docker/bag_files:consistent + - shared_data:/etc/docker/shared_data:consistent + env_file: + - ./stack.env + tty: true + command: bash -c "waitForTime && /etc/docker/shared_data/record.sh" + + takeoff: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + depends_on: + - roscore + network_mode: host + volumes: + - shared_data:/etc/docker/shared_data:consistent + env_file: + - ./stack.env + tty: true + command: bash -c "waitForControl && rosservice call /uav1/hw_api/arming 1 && sleep 1 && rosservice call /uav1/hw_api/offboard" + + rviz: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + depends_on: + - roscore + network_mode: host + volumes: + - shared_data:/etc/docker/shared_data:consistent + # mount the folders below to enable passing GUI to the host + - /dev/dri:/dev/dri + env_file: + - ./stack.env + environment: + DISPLAY: $DISPLAY + tty: true + command: bash -c "waitForHw && roslaunch mrs_uav_core rviz.launch" + + rviz_interface: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + depends_on: + - roscore + network_mode: host + volumes: + - shared_data:/etc/docker/shared_data:consistent + # mount the folders below to enable passing GUI to the host + - /dev/dri:/dev/dri + env_file: + - ./stack.env + environment: + DISPLAY: $DISPLAY + tty: true + command: bash -c "waitForHw && roslaunch mrs_rviz_plugins rviz_interface.launch" + + dogtail: + image: klaxalk/dogtail:latest + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - logs:/etc/logs:consistent + + # this container can be used to access a terminal with ROS inside the compose session + terminal: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + network_mode: host + env_file: + - ./stack.env + entrypoint: ["/bin/bash", "-c"] + volumes: + - shared_data:/etc/docker/shared_data:consistent + - bag_files:/etc/docker/bag_files:consistent + - /dev/:/dev/ + - /tmp/.X11-unix:/tmp/.X11-unix + command: + - bash --rcfile /opt/ros/noetic/setup.bash + privileged: true + stdin_open: true + tty: true +``` + +
+ +
+Environment variables + +```bash +RUN_TYPE=simulation +UAV_NAME=uav1 +UAV_TYPE=x500 +ROS_MASTER_URI=http://localhost:11311 +MRS_UAV_SYSTEM_VERSION=1.5.0 +DISPLAY=:0 +``` + +
+ +## Example realworld UAV session + +An example realworld session is located at [mrs_docker/tree/master/compose/1.5.0/portainer](https://github.com/ctu-mrs/mrs_docker/tree/master/compose/1.5.0/portainer). +Custom configs for the MRS UAV System are supposed to be packed into a transport docker image. +The subfolder `custom_configs` containes the example custom cofigs and scripts for build an image that is going to unload the configs during the runtime for the running containers. + +
+Compose file + +```yaml +volumes: + + shared_data: + + bag_files: + + logs: + +services: + + # will copy session-specific data shared between containers from the shared_data container to a shared volume + copy_shared_data: + image: shared_data_gnss + 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/" + + # starts roscore + # this is the first container in the ROS pipeline + roscore: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + network_mode: host + depends_on: + - copy_shared_data + env_file: + - ./stack.env + tty: true + command: roscore + + # after roscore is started + # -> set a parameter that tells the system that simulation time is NOT used + # this container then stops + rostime: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + network_mode: host + depends_on: + - roscore + env_file: + - ./stack.env + tty: true + command: bash -c "waitForRos && rosparam set use_sim_time false" + + # starts the HW API for connecting the MRS UAV System to PX4 + hw_api: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + depends_on: + - rostime + network_mode: host + volumes: + - shared_data:/etc/docker/shared_data:consistent + - /dev/:/dev/ + privileged: true + env_file: + - ./stack.env + tty: true + command: bash -c "waitForTime && roslaunch mrs_uav_px4_api api.launch" + + # starts the MRS UAV System's core + uav_core: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + depends_on: + - rostime + network_mode: host + volumes: + - shared_data:/etc/docker/shared_data:consistent + env_file: + - ./stack.env + tty: true + command: bash -c "waitForHw && roslaunch mrs_uav_core core.launch platform_config:=`rospack find mrs_uav_deployment`/config/mrs_uav_system/${UAV_TYPE}.yaml custom_config:=/etc/docker/shared_data/custom_config.yaml world_config:=/etc/docker/shared_data/world_local.yaml network_config:=/etc/docker/shared_data/network_config.yaml" + + # starts the node that handles automatic initialization of the system and takeoff + automatic_start: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + depends_on: + - rostime + network_mode: host + volumes: + - shared_data:/etc/docker/shared_data:consistent + env_file: + - ./stack.env + tty: true + command: bash -c "waitForHw && roslaunch mrs_uav_autostart automatic_start.launch" + + # starts `rosbag record` + rosbag: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + depends_on: + - rostime + network_mode: host + volumes: + - bag_files:/etc/docker/bag_files:consistent + - shared_data:/etc/docker/shared_data:consistent + env_file: + - ./stack.env + tty: true + command: bash -c "waitForTime && /etc/docker/shared_data/record.sh" + + rosbridge: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + network_mode: host + env_file: + - ./stack.env + tty: true + command: bash -c "waitForRos && roslaunch rosbridge_server rosbridge_websocket.launch" + + dogtail: + image: klaxalk/dogtail:latest + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - logs:/etc/logs:consistent + + # this container can be used to access a terminal with ROS inside the compose session + terminal: + image: ctumrs/mrs_uav_system:${MRS_UAV_SYSTEM_VERSION} + network_mode: host + depends_on: + - rostime + env_file: + - ./stack.env + entrypoint: ["/bin/bash", "-c"] + volumes: + - bag_files:/etc/docker/bag_files:consistent + - shared_data:/etc/docker/shared_data:consistent + - /dev/:/dev/ + command: + - bash --rcfile /opt/ros/noetic/setup.bash + privileged: true + stdin_open: true + tty: true +``` + +
+ +
+Environment variables + +```bash +RUN_TYPE=realworld +UAV_NAME=uav80 +UAV_TYPE=x500 +ROS_MASTER_URI=http://localhost:11311 +UAV_MASS=2.0 +MRS_UAV_SYSTEM_VERSION=1.5.0 +``` + +
diff --git a/docs/10-prerequisities/32-portainer/fig/portainer_login.png b/docs/10-prerequisities/32-portainer/fig/portainer_login.png new file mode 100644 index 00000000..33c9d158 Binary files /dev/null and b/docs/10-prerequisities/32-portainer/fig/portainer_login.png differ diff --git a/docs/10-prerequisities/32-portainer/index.md b/docs/10-prerequisities/32-portainer/index.md new file mode 100644 index 00000000..2e880aa9 --- /dev/null +++ b/docs/10-prerequisities/32-portainer/index.md @@ -0,0 +1,20 @@ +--- +title: Portainer.io +pagination_label: Deploying Docker with Portainer.io +description: Deploying Docker with Portainer.io +--- + +# Portainer.io + +[Portainer](https://www.portainer.io/) can be described as a **web UI for docker**. +It allows you to easily +* manage existing docker images on your robot, +* upload new docker images (either throught Docker API or by file upload), +* create and edit compose sessions, +* start and stop compose sessions, +* inspect and manager docker volumes, +* introspect and manage running containers. + +import DocCardList from '@theme/DocCardList'; + +