Install Docker in Raspberry Pi 4

From Chorke Wiki
Jump to navigation Jump to search
df -h
vcgencmd measure_temp
apt list --upgradable
apt upgrade

apt install openjdk-8-jdk/stable
apt install openjdk-11-jdk/stable
df -h

curl -sSL https://get.docker.com | sh
usermod -aG docker pi
docker --version
df -h

docker run hello-world
docker ps -a
docker images

apt install libffi-dev libssl-dev
apt install python3 python3-pip
apt remove python-configparser
pip3 install docker-compose
df -h

Networking

cat <<EOF > /etc/docker/daemon.json
{
    "bip"  : "10.20.13.1/24",
    "mtu"  : 1500,
    "dns"  : [
        "10.19.83.100",
        "10.19.83.1"
    ],
    "debug": true
}
EOF
cat <<EOF > /etc/docker/daemon.json
{
    "mtu"   : 1500,
    "debug" : true,
    "experimental": false,
    "default-address-pools" :[{
        "base"  : "10.20.0.0/16",
        "size"  : 24
    }]
}
EOF
apt install -y iputils
iptables -t nat -S

service docker stop
service docker start

docker run --rm --detach --publish 1983:80 nginx
docker run --rm --detach --net=host nginx

docker run --rm --detach --publish 1983:80 --net=ckn.b00 --ip 10.20.15.10 nginx
docker run --rm --detach --publish 1983:80 --net=ckn.b01 --ip 10.20.16.10 nginx

Bridge

docker network create \
--driver bridge \
--gateway  10.20.15.1 \
--subnet   10.20.15.0/24 \
--opt com.docker.network.driver.mtu=1500 \
--opt com.docker.network.bridge.enable_icc=true \
--opt com.docker.network.bridge.enable_ip_masquerade=true \
--opt com.docker.network.bridge.host_binding_ipv4=0.0.0.0 \
--opt com.docker.network.bridge.name=ckn.b00 ckn.b00

Cache or Mirror

mkdir -p /etc/docker/registry
cat <<EOF > /etc/docker/registry/config.yml
proxy:
  remoteurl: https://hub.chorke.org
  username: academia
  password: sadaqah!
EOF

Troubleshoot

docker run --rm --net=host busybox nslookup google.com
docker run --rm --net=host alpine cat /etc/resolv.conf
docker run --rm --net=host alpine nslookup google.com
docker run --rm --net=host alpine ping google.com
docker run --rm --net=host alpine cat /etc/hosts
docker run --rm --net=host alpine ifconfig
docker run --rm --net=host alpine ip addr
docker run --rm --net=host alpine route
docker run --rm busybox nslookup google.com
docker run --rm alpine cat /etc/resolv.conf
docker run --rm alpine nslookup google.com
docker run --rm alpine ping google.com
docker run --rm alpine cat /etc/hosts
docker run --rm alpine ifconfig
docker run --rm alpine ip addr
docker run --rm alpine route
cat /etc/docker/registry/config.yml
cat /etc/docker/daemon.json
cat ~/.docker/config.json
docker info

References