Ubuntu20.04+Docker+ROS Noetic Visual Container Management Tool Portainer

1. Install docker

Official website teaching installation website: Install Docker Engine on Ubuntu | Docker Documentation

2. Install the noetic image

ros mirror URL

https://hub.docker.com/r/osrf/ros

https://hub.docker.com/r/osrf/ros/tags

sudo docker pull osrf/ros:noetic-desktop-full

3. Create the container

3.1 The host machine opens xhost, making the visual interface in docker (vscode rviz)

xhost(参数)
//+:关闭访问控制,允许任何主机访问本地的X服务器;
//-:打开访问控制,仅允许授权清单中的主机访问本地的X服务器。

 Note: Every time the container is restarted, the host has to execute it again, otherwise a visual error will be reported in the container.

3.2 Create a host data folder as a data container volume with the container

3.3 Create a container and mount the data container volume

create container

sudo docker run -it -v /home/nuc/noetic_container_data_1:/data --device=/dev/dri --group-add video --volume=/tmp/.X11-unix:/tmp/.X11-unix  --env="DISPLAY=$DISPLAY" --env="QT_X11_NO_MITSHM=1" --name=noetic_ros_2 osrf/ros:noetic-desktop-full  /bin/bash

Must add:

--env="QT_X11_NO_MITSHM=1"

Otherwise, the inside of docker cannot be visualized (the host must first execute the xhost + command)

view container
 

sudo docker ps //查看正在运行的容器

sudo docker ps -a //查看所有的容器

Test whether the host and container data are synchronized

  • initial state 

  • The host creates a file: 

The container presents this file:

  • The container creates a file 

The file appears on the host: 

3.4 Exiting a container and entering it again

quit

View container ID

enter again 

sudo docker start -ia [container_id]

Shut down the running container

sudo docker stop id

4. ROS Noetic test

4.1 Open a terminal in the container (error, the environment is not synchronized)

sudo docker exec -it your-docker-id /bin/bash

4.2 Using tmux

(43 messages) tmux common commands and shortcuts

Install

sudo apt-get update
sudo apt install tmux

Split screen with tmux

tmux

Then press ctrl+b first, then press c, two bash will appear below

Press ctrl+b first, then press p to return to the previous bash;

Press ctrl+b first, then press n to return to the next bash;

Open roscore on the left, and open rviz on the right terminal

#left
roscore

#right
rviz

 Close a window of tmux

First press ctrl+b, then press x, and then press y;

4.2 View the little turtle

Press ctrl+b, followed by c, and a total of 3 windows will be built

first window input

roscore

Enter the second window

rosrun turtlesim turtlesim_node

 third window input

rosrun turtlesim turtle_teleop_key

Then you can control the little turtle with the direction buttons

Install the visual container management tool Portainer 

sudo docker pull portainer/portainer

sudo docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock --restart=always --name prtainer portainer/portainer

Open the IE browser, enter the ip:9000 port, create a new account and password, you can enter the following docker management interface, with this tool, we can save us from learning docker-related console commands again, and view the installed docker in the visual interface Docker containers and running docker images.

 So far the installation is successful!

reference:

Ubuntu20.04+Docker+ROS Noetic+LOAM environment configuration

How to build a ROS development environment for Ubuntu 20.04_ubuntu20.04 ros docker_weixin_39563394's Blog

おすすめ

転載: blog.csdn.net/weixin_45897172/article/details/131599195