Archive for 3月, 2022

在Vyos上安装Docker

Posted by on 星期五, 25 3月, 2022

Install Docker on Vyos

At first, here is the shell script(link) which including all the following steps, so you can install Docker on your Vyos easier.

  • Add Debian source to Vyos
    don’t forget to replace “buster” with your own Linux release codename, you can check it by “lsb_release -c”.

$sudo echo deb http://archive.debian.org/debian buster main >> /etc/apt/sources.list

  • Update

$sudo apt-get update

  • Install gpg key

$sudo apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common

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

  • Add Docker source

$sudo echo deb [arch=amd64] https://download.docker.com/linux/debian buster stable > /etc/apt/sources.list.d/docker.list

  • Update

$sudo apt-get update

  • Install Docker

$sudo apt-get install -y docker-ce docker-ce-cli containerd.io

Advanced

  • Install docker-compose

$sudo wget https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-Linuxx86_64 -P /var/lib/docker/

v2.2.2 is the version of docker-compose, you can check docker-compose released version here: Releases · docker/compose · GitHub
Linux is your os type, you can check by “uname -s”
x86_64 is your Linux architecture, you can check by “uname -m”

After download you can link docker-compose to a bin directory by

$sudo ln -s /var/lib/docker/docker-compose /usr/local/bin/docker-compose

  • Using Vyos bridge interface instead of Docker network

There will be a default bridge(docker0) created by Docker, if you want to manage this bridge by Vyos, this part will help you.

Add bridge to Vyos

 

  • Using Vyos route instead of  Docker iptables forward

 

1.Add Debian source to Vyos, don’t forget to replace “jessie” with your own Linux release codename, you can check it by “lsb_release -c”

/etc/apt/sources.list

deb http://deb.debian.org/debian jessie main contrib non-free

sudo apt update

sudo apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common

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

deb https://download.docker.com/linux/debian jessie stable

sudo apt update

sudo apt install -y docker-ce

set system login user vyos group docker

 

Docker and iptables | Docker Documentation

 

禁用Docker iptables

删掉默认docker0,使用br0

sudo ip link set docker0 down

brctl delbr docker0

 

删掉原有网络配置sudo rm /var/lib/docker/network –rf

sudo cat /etc/docker/daemon.json

{

“debug”: true,

“iptables”: false,

“bridge”: “br0”

}

 

安装docker compose

Releases · docker/compose · GitHub

/usr/local/bin/docker-compose

 

docker network create -o com.docker.network.bridge.name=br110 private

apt-get install iputils-ping

apt install iproute2

apt-get install net-tools

 

docker repo