Dockerfile: Malformed entry 1 in list file /etc/apt/sources.list.d/ros2.list

asked 2022-09-28 15:01:30 -0500

I'm trying to install ROS in Dockerfile. Here is the part of my Dockerfile that installs ROS 2 Foxy (basically, it copies the official instruction):

FROM ubuntu:20.04
RUN apt update && apt install -y locales && locale-gen en_US en_US.UTF-8 && export LANG=en_US.UTF-8
RUN apt install -y software-properties-common && add-apt-repository universe
RUN apt update && apt install -y curl gnupg2 lsb-release && curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key  -o /usr/share/keyrings/ros-archive-keyring.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null
RUN apt update
RUN apt upgrade -y
RUN apt install -y ros-foxy-desktop

When I run it I have the following error:

Step 18/23 : RUN apt update
 ---> Running in 62c58cd09ed3

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

E: Malformed entry 1 in list file /etc/apt/sources.list.d/ros2.list (Component)
E: The list of sources could not be read.
The command '/bin/sh -c apt update' returned a non-zero code: 100

I understand that something's wrong with this command: RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null but I don't understand how to fix it

edit retag flag offensive close merge delete

Comments

1

Just a quick note/question: you may already know, but official docker images are available, including ROS 2 Foxy. Even if you'd like to customise the installation (ie: install additional packages) you could still make use of those.

gvdhoorn gravatar image gvdhoorn  ( 2022-09-30 01:23:23 -0500 )edit

gvdhoom, thank you for the information. I guess it solves my problem

eons_stills_0r gravatar image eons_stills_0r  ( 2022-09-30 16:04:01 -0500 )edit