Skip to content

Raspberry Pi 2 Docker

blahlt edited this page Dec 15, 2020 · 6 revisions
  1. Sudiegiam Docker:
pi@raspberrypi:~ $ curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
  1. Įtraukiam vartotoją į docker grupę, kad Docker komandos veiktų su šiuo (pi) vartotoju:
pi@raspberrypi:~ $ sudo gpasswd -a $USER docker
  1. Padarom logout ir login arba paleidžiam komandą, kad pakeitimai įsigaliotų:
pi@raspberrypi:~ $ sudo newgrp docker
  1. Sustabdom docker ir containerd servisus:
pi@raspberrypi:~ $ sudo systemctl stop docker
pi@raspberrypi:~ $ sudo systemctl stop containerd
  1. Sukuriam /mnt/pihdd/containerd/root ir /mnt/pihdd/containerd/state katalogus:
pi@raspberrypi:~ $ sudo mkdir -p /mnt/pihdd/containerd/root
pi@raspberrypi:~ $ sudo mkdir -p /mnt/pihdd/containerd/state
  1. Sukonfigūruojam containerd, kad duomenys būtų išoriniam diske:
pi@raspberrypi:~ $ sudo nano /etc/containerd/config.toml

ir pakeičiam root ir state reikšmes atitinkamai į /mnt/pihdd/containerd/root ir /mnt/pihdd/containerd/state

  1. Sukuriam katalogą docker'iui ir perkeliam failus
pi@raspberrypi:~ $ sudo mkdir /mnt/pihdd/docker
pi@raspberrypi:~ $ sudo rsync -aqxP /var/lib/docker/ /mnt/pihdd/docker
  1. Sukonfigūruojam servisą:
pi@raspberrypi:~ $ sudo nano /lib/systemd/system/docker.service

ir pakeiciam eilutę
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
į
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -g /mnt/pihdd/docker

  1. Startuojam docker servisą (kartu startuoja ir containerd servisas):
pi@raspberrypi:~ $ sudo systemctl daemon-reload
pi@raspberrypi:~ $ sudo systemctl start docker
  1. Patikrinam ar veikia docker servisas:
pi@raspberrypi:~ $ sudo systemctl is-active docker
  1. Paleidžiam konteinerį:
pi@raspberrypi:~ $ docker run arm32v7/hello-world

Unable to find image 'arm32v7/hello-world:latest' locally
latest: Pulling from arm32v7/hello-world
4ee5c797bcd7: Pull complete
Digest: sha256:d32a4c07ce3055032a8d2d59f49ca55fafc54a4e840483b590f7565769dc7e00
Status: Downloaded newer image for arm32v7/hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (arm32v7)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Links:

Clone this wiki locally