Skip to main content

Docker

This page provides some examples for how to run the DroneDeploy Agent, in conjunction with ROS, in a Docker container. Note that there are a large number of possible configurations and topologies by which you could run the Agent in a container, so use these examples as a guide for creating your own container images.

Agent & ROS Master in a Single Container

Create a docker file to generate an image, based on Ubuntu Xenial, which includes both ROS and the Agent combined together:

FROM ubuntu:xenial

# install prerequisites
RUN apt-get update && apt-get install -y apt-transport-https gnupg ca-certificates

# install ROS
RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu xenial main" > /etc/apt/sources.list.d/ros-latest.list'
RUN apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
RUN apt-get update && apt-get install -y ros-kinetic-ros-base curl

# install DroneDeploy Agent
RUN sh -c 'echo "deb https://packages.rocos.io/apt stable main " > /etc/apt/sources.list.d/rocos.list'
RUN sh -c 'curl https://packages.rocos.io/apt/docs/key.gpg | apt-key add -'
RUN apt-get update && apt-get install rocos-agent -y

COPY ./run.sh /
RUN chmod +x /run.sh

# declare env vars to be populated at container run time with --env flag
ENV agent_pat ""
ENV agent_callsign ""
ENV agent_name ""

# run the agent and ros master
ENTRYPOINT ["/run.sh"]

This container image runs a script at startup, this script starts ROS as well as the Agent:

#!/usr/bin/env bash

set -e

# setup ros environment
source "/opt/ros/kinetic/setup.bash"

# run the rosmaster
roscore &

# run the agent
exec rocos-agent -p "${agent_pat}" -c "${agent_callsign}" -n "${agent_name}" -f -d

Note that you need to provide the necessary information for provisioning the Agent (PAT, callsign and name) to the container using the environment flag.