The dockerfile
should be something like
# If amd64 architecture
# FROM osrf/ros:melodic-desktop-full-bionic
# If arm64 architecture
FROM arm64v8/ros:melodic
# uncomment ARG if you need to interact with a remote repository
# ARG SSH_PRIVATE_KEY
RUN apt update && apt install -y \
libboost-all-dev \
python-catkin-tools \
# To use ssh-keyscan
ssh \
# Necessary for creating debian packages out of ros packages
python-bloom \
fakeroot \
dpkg-dev \
debhelper \
# Clean apt list
&& rm -rf /var/lib/apt/lists/*
# Uncomment in case you need to interact (clone/push) a remote git repo
# RUN mkdir /root/.ssh/ \
# # setup ssh, with the private-key argument
# && echo "${SSH_PRIVATE_KEY}" > /root/.ssh/id_rsa \
# # git requires a private key with strict permission settings for authentication via SSH
# && chmod 600 /root/.ssh/id_rsa \
# # add github to known hosts
# && touch /root/.ssh/known_hosts \
# && ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts
# RUN git clone <git-repo> <desired path>
# Assuming that the dockerfile is in you workspace,
# add all the files from the workspace to the image
ADD . /home
Having the dockerfile
, now run
docker build --tag my_ros_image:1.0 .
or
docker build --build-arg SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)" --tag my_ros_image:1.0 .
if you need to pass ssh-keys
, be aware that your ssh keys will be available for anyone that has access to your image
docker run --rm -it my_ros_image:1.0
One should run the following commands
rosdep update
catkin clean -y
One may need to run catkin config
to setup the build pipeline with CMAKE
arguments or install
from ROS, such as catkin config --cmake-args -DARCHI=arm64
Then build
catkin build
change directory to your package:
cd /home/src/my_package
then run
bloom-generate rosdebian --os-name ubuntu --ros-distro melodic
fakeroot debian/rules binary
cat /proc/self/cgroup | grep -o -e "docker-.*.scope" | head -n 1 | sed "s/docker-\(.*\).scope/\\1/"
get Docker Linux container information from within the container itself
docker cp <containerId>:/file/path/within/container /host/path/target
copying files from container to host
In case you find and error like
Error of catkin build: Unable to find source space
Run rm -rf ./.catkin_tools
in the path has catkin_tools