[Docker] 制作使用bionic +ros2的docker镜像

一 、安装docker 


    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - 

    sudo apt-key fingerprint 0EBFCD88 

    sudo add-apt-repository  "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" 

    sudo apt-get update 

    sudo apt-get install docker-ce docker.io 

    systemctl daemon-reload 

    systemctl restart docker 
  1. 测试: docker pull hello-world 

                       docker run hello-world 

二、制作bionic+ros2 docker 

1. 下载img 

docker pull osrf/ros2:devel 

2. 进入docker  

docker run -it --rm --volume=/tmp/.X11-unix:/tmp/.X11-unix:rw --volume=/home/weilin/.Xauthority:/home/weilin/.Xauthority:rw --volume=/home/weilin/shared_dir:/home/autoware/shared_dir:rw  --env=XAUTHORITY=/home/weilin/.Xauthority  --env=DISPLAY=:0  --env=USER_ID=1000 --privileged     --net=host    osrf/ros2:devel '/bin/bash'   

3.  安装一些依赖 
 

curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - 

sudo sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list' 

sudo apt update 
sudo apt install ros-dashing-desktop 

4. 打包镜像 

docker commit -a "Lin" -m "bionic_ros2" 80955a78f696  bionic_ros2:v0 

5. 保存镜像: 

docker image save bionic_ros2:v0  -o bionic_ros2.tar 

三、使用bionic+ros2 docker 

1. docker load -i bionic_ros2.tar 

2. docker run -it autocore_base:v0  '/bin/bash'   (参数根据需要自己添加) 

四、使用bionic+ros2+nv docker 

http://wiki.ros.org/docker/Tutorials/Hardware%20Acceleration#Intel 

https://github.com/nvidia/nvidia-docker/wiki/Installation-(version-2.0) 

sudo apt-get install nvidia-docker2 
sudo pkill -SIGHUP dockerd 

Dockerfilegen 中FROM osrf/ros:需要更改一下,其他同步骤二 

你可能感兴趣的:(ros)