Skip to content


ardupilot  None  ros2  dds  micro ros  xrce  lua  sitl  scripts  plugin  gazebo  garden  SITL  debug  mavlink  gimbal  rangefinder  pymavlink  mavros  distance sensor  system_time  timesync  ardurover  script  cheat sheet  wireshark  mavproxy  mission planner  pixhawk  cpp  index  cmake  gtest  ctest  demo  101  variables  cpack  deb  package  dpkg  eigen  linear algebra  c++  format  fmt  smart pointers  data structure  map  container  multithreading  spdlog  cyclonedds  eprosima  fastdds  aptly  apt  repository  repo  local  mirror  encryption  pgp  docker  arm  qemu  state  networking  network  template  python  app  devcontainer  gui  tutorial  tips  volume  mount  compose  multi-stage  stage  docker compose  microsoft  dotnet  .net  c#  vscode  git  branch  tag  bundle  backup  hooks  pre-commit  submodules  marpit  presentation  marp  markdown  mermaid  mkdocs  video  ffmpeg  gstreamer  cheat-sheet  sdp  nvidia  opencv  appsrc  appsink  acceleration  va-api  intel  v4l2loopback  pipe  compositor  alpha  shmsink  shmsrc  intersink  intersrc  tee  queue  udp  stream  klv  misb  mpeg-ts  gst  mpeg  metadata  binding  gi  kml  geo  gis  spatial  gdal  ogr  raster  vector  qgc  qgroundcontrol  snippets  cheat Sheet  asyncio  event  future  thread  task  can  canbus  click  cli  cupy  numpy  gpu  dataclass  slots  dev container  fastapi  rest  uvicorn  debian  setup  stdeb  project  jupyter  widgets  interactive  plot  matplotlib  ipywidgets  3d  subplot  open3d  point cloud  packaging  pyproject  pipx  package manager  black  isort  templates  cookiecutter  docs  project document  docstrings  flake8  linter  git-hook  mypy  unittest  pytest  pylint  from a-z  fixture  scope  logging  pytest.ini  mock  parameterize  enum  flag  iterator  generator  yaml  yml  logging config  tuple  namedtuple  typing  annotation  generic  literal  protocol  self  typed dict  typevar  pyzmq  zmq  msgpack  slam  cartographer  slam_toolbox  build system  colcon  action  namespace  remap  control2  diff-drive  ignition  ros2_control  effort  velocity  gdb  mix  multi language  qos  plugins  ros  pub  sub  msg  node  time  rclcpp  parameters  zero-copy  shm  loan message  rmw  image  large message  discovery  zenoh  bridge  zenoh-plugin-ros2dds  pico  algorithm  calibration  diff  pid  dev  colcon_cd  clean  custom  bloom  rpi  core  settings  behavior  py_trees  bt  behavior_trees  blackboard  visualization  debugging  diagnostic  DiagnosticTask  rclpy  tutorials  diagnostics  math  ned  enu  coordinate  apm  rat_runtime_monitor  bag  rosbag  rosbags  tools  smach  state machine  yasmin  web  rosbridge  vue  profile  gazebo-classic  launch  spawn  model  cook  camera  sensors  gps  imu  ray  gazebo_ros_ray_sensor  lidar  ultrsonic  range  ultrasonic  gazebo classic  wrench  gazebo_ros_state  gz  sdf  world  vscode tips  gazebogz-sim-joint-position-controller-system  simulation  ros_gz_bridge  ign  xacro  diff_drive  odom  odometry  joint_state  argument  OpaqueFunction  DeclareLaunchArgument  LaunchConfiguration  tmux  tmuxp  nav  nav2  turtlebot  perception  tf  vision  cv_bridge  setup.py  name  test  goal abort  cancel goal  action client  action server  custom messages  executor  MultiThreadedExecutor  SingleThreadedExecutor  lifecycle  parameter  param  dynamic-reconfigure  get  global server  persist_parameter  service  client  package.xml  msgs  executers  rep  rqt  humble  rviz  rviz2  pose  marker  tf2  static  graphro  local_setup  rosdep  project settings  vcstool  urdf  robot_state_publisher  urdf_to_graphiz  joint  link  robotics  path planning  trajectory  speed  filters  control  kalman_filter  kalman  filter  pcl  fusing  foc  bldc  arduino  drv8313  simple foc  quaternions  euler  rotation  code  extensions  remote  cache  offline  ssh  tasks  json  schema  server  deep learning  ai  beginner  regression  reinforcement learning  q learning  gym  gymnasium  deepsort  onnx  inference  build  source  wheel  cuda  siam-mask  tracking  segmentation  yolo  ultralytics  yolov8  jetson  tensorrt  rest api  js  javascript  async  alpine.js  mqtt  nano  terabee  i2c  l6234  blink  platformio  lw20  benewake  TF03  serial  tf_mini  libs  cross-compiler  esp32  idf  esp-idf  rtos  hello world  mp6050  mpu9250  mpu6050  embedded  kconfig  semaphore  mutex  timer  adafruit  sensor  mb1202  uart  tfmini  gpio  raspberry pi  arducam  lidat  ubuntu  stm32  nucleo  mbed  blue pill  swd  library  teensy  microros  udev  rule  usb  micro python  pymakr  config  material  workshope  classic  texture  topic  gzstring  position  force  joints  loop device  rootfs  linux  rm  sudo  sudoers  nopasswd  visudo  shell  key  gpg  sign  commands  update-alternative  debconf  dpkg-show  dpkg-reconfigure  debconf-communicate  ip  ss  netstat  systemd  socat  tc  mtu  select  projects  courses to follow  matrix  graphics  2d  course  storm32  deploy  drone  quad  uav  geometric control  se3  so3  joint_states  JointState  Header  rrbot  JointTrajectory  gazebo_ros_joint_pose_trajectory  vrx  buoyancy 

Docker Networking#

Out of the box docker has three type of networks

docker network ls
#
NETWORK ID     NAME      DRIVER    SCOPE
518ee43b204b   bridge    bridge    local
b995620ac824   host      host      local
0ca19644e7f5   none      null      local

Bridge Network#

This is the default network that container attached by default, the docker engine create a network interface on host usually with an ip address 172.17.0.1/16 and the container get ip address from dhcp config on this interface. run docker network inspect bridge for more information on the configuration and container attach to this network.

Host Network#

Host network use the host’s network and not receive an ip address. They are virtually a service spawned on the host’s network and consume the host’s ports.

docker run -it --rm \
--network=host \
busybox

None Network#

A none network doesn’t provide any networking capability to the container which means the container is like a black box to the host. The host or any other container won’t be able to communicate with the container.

docker run -it --rm \
--network=none \
busybox
ifconfig
# only localhost exists 
lo      Link encap:Local Loopback  
        inet addr:127.0.0.1  Mask:255.0.0.0
        ...

MacVLAN Network#

docker network create -d macvlan \
--subnet=192.168.100.0/24 \
--gateway=192.168.100.1 \
-o parent=wlo1 \
pub_net
docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
518ee43b204b   bridge    bridge    local
b995620ac824   host      host      local
0ca19644e7f5   none      null      local
2e404239b3e6   pub_net   macvlan   local
docker run -it --rm \
--network=pub_net \
busybox

Note

macvlan can only communicate with other container on the same vlan

Custom bridge#

docker network create -d bridge my_bridge
docker network ls
#
NETWORK ID     NAME        DRIVER    SCOPE
518ee43b204b   bridge      bridge    local
b995620ac824   host        host      local
267224cb8d5c   my_bridge   bridge    local
0ca19644e7f5   none        null      local
docker network inspect my_bridge
#
[
    {
        "Name": "my_bridge",
        "Id": "267224cb8d5cb2d4626549c4082fcb7ff58f14ed67365ddc301de1e1ed8f1b23",
        "Created": "2023-07-06T15:24:31.8552333+03:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },

Tip

A bridge network construct its own DNS. The hostname of each container mapped to its IP address

Demo#

Show using DNS on custom bridge network

container1
docker run -it --rm \
--hostname=drone \
--name=done_c \
--network=my_bridge \
busybox
container2
docker run -it --rm \
--hostname=ai \
--network=my_bridge \
busybox
container1
hostname -i
172.18.0.2

hostname -f
drone

ping ai
64 bytes from 172.18.0.3: seq=0 ttl=64 time=0.120 ms
container2
hostname -i
172.18.0.3

hostname  -f
ai

ping drone
PING drone (172.18.0.2): 56 data bytes
64 bytes from 172.18.0.2: seq=0 ttl=64 time=0.100 ms

Add network adapter to container#

docker network connect <network> <container>

Demo#

  • Add default bridge to running container with my_bridge network
container1
docker run -it --rm \
--hostname=drone \
--name=drone_c \
--network=my_bridge \
busybox
connect
docker network connect bridge drone_c
ifconfig 
eth0      Link encap:Ethernet  HWaddr 02:42:AC:12:00:02  
          inet addr:172.18.0.2  Bcast:172.18.255.255  Mask:255.255.0.0
          ...

eth1      Link encap:Ethernet  HWaddr 02:42:AC:11:00:05  
          inet addr:172.17.0.5  Bcast:172.17.255.255  Mask:255.255.0.0
          ...
disconnect
docker network disconnect bridge drone_c

resources#