docker容器搭建ROS环境
1.准备ubuntu16.04的基础镜像
docker pull ubuntu:16.04
2.创建Dockerfile文件
mkdir -p /opt/Dockerfile
cat << EOF > /opt/Dockerfile/Dockerfile
FROM ubuntu:16.04
MAINTAINER yourname
RUN apt-get update
RUN apt-get -y install curl vim net-tools wget
RUN 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 curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | apt-key add -
RUN apt-get update
RUN apt-get install ros-kinetic-ros-base -y
RUN apt-cache search ros-kinetic
RUN rosdep init
RUN echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
RUN apt-get -y install python-rosinstall python-rosinstall-generator python-wstool build-essential
CMD ["/bin/bash"]
EOF
3.制作镜像
cd /opt/Dockerfile
docker build -t ubuntu16.04:ros .
4.启动ros容器
docker run -dit --name ros --hostname=ros ubuntu16:ros
5.进入容器启动ros
docker exec -it ros /bin/bash
roscore &