Install Docker in Raspberry Pi 4: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
(Created page with "<source lang="bash"> 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:/...")
 
 
(7 intermediate revisions by the same user not shown)
Line 25: Line 25:
</source>
</source>


== References ==
==Networking==
{|
| valign="top" |
<source lang="json">
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
</source>
 
| valign="top" |
<source lang="json">
cat <<EOF > /etc/docker/daemon.json
{
    "mtu"  : 1500,
    "debug" : true,
    "experimental": false,
    "default-address-pools" :[{
        "base"  : "10.20.0.0/16",
        "size"  : 24
    }]
}
EOF
</source>
|}
<source lang="bash">
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
</source>
 
===Bridge===
<source lang="bash">
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
</source>
 
==Cache or Mirror==
<source lang="properties">
mkdir -p /etc/docker/registry
cat <<EOF > /etc/docker/registry/config.yml
proxy:
  remoteurl: https://hub.chorke.org
  username: academia
  password: sadaqah!
EOF
</source>
 
==Troubleshoot==
{|
| valign="top" |
<source lang="bash">
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
</source>
 
| valign="top" |
<source lang="bash">
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
</source>
|}
 
cat /etc/docker/registry/config.yml
cat /etc/docker/daemon.json
cat ~/.docker/config.json
docker info
 
==References==
* [https://dev.to/rohansawant/installing-docker-and-docker-compose-on-the-raspberry-pi-in-5-simple-steps-3mgl Installing Docker Compose on Raspberry Pi 4]
* [https://www.docker.com/blog/happy-pi-day-docker-raspberry-pi/ Happy Pi Day with Docker and Raspberry Pi]
* [https://docs.docker.com/registry/recipes/mirror/#run-a-registry-as-a-pull-through-cache Run a Registry as a pull-through Cache]
* [https://medium.com/@sipkeschoorstra/installing-docker-on-raspberry-pi-4-b010d3792b2d Installing Docker on Raspberry Pi 4]
* [https://medium.com/@sipkeschoorstra/installing-docker-on-raspberry-pi-4-b010d3792b2d Installing Docker on Raspberry Pi 4]
* [https://dev.to/rohansawant/installing-docker-and-docker-compose-on-the-raspberry-pi-in-5-simple-steps-3mgl Installing Docker Compose on Raspberry Pi 4]

Latest revision as of 04:04, 3 January 2021

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