Docker

라즈베리파이(RaspberryPi), 도커 (Docker) 설치하기

LEEHANDS 2022. 2. 15. 10:38
반응형

 

https://dev.to/elalemanyo/how-to-install-docker-and-docker-compose-on-raspberry-pi-1mo

 

How To Install Docker and Docker-Compose On Raspberry Pi

RaspberryPi ARMed with Docker and Docker-Compose

dev.to

 

라즈베리파이에 도커를 설치해보려고한다.

콘테이너라고하는 도커 과연 얼마나 편하고 자료 보관에 유용할지 사용해보자

 

일단 라즈비안 32bit 최신 버전으로 설치한다.

2022년 2월 15일 기준 최신은 

 

1. Install Docker

1-1 Update & Upgrade

1-2 Install Docker

curl -sSL https://get.docker.com |sh

1-3 Add a Non-Root User to the Docker Group

기본적으로 관리 권한이 있는 사용자(루트 사용자)만 컨테이너를 실행할 수 있습니다. 루트로 로그인하지 않은 경우 한 가지 옵션은 sudo 접두사를 사용하는 것입니다.
그러나 루트가 아닌 사용자를 Docker 그룹에 추가하여 docker 명령을 실행할 수도 있습니다.

 

Docker 그룹에 사용자를 추가하는 구문은 다음과 같습니다.

sudo usermod -aG docker [user_name]

현재 사용자에게 권한을 추가하려면 다음을 실행하십시오.

sudo usermod -aG docker ${USER}

Check it running:

groups ${USER}

== REBOOT ==

 

1-4. Install Docker-Compose

Docker-Compose는 일반적으로 pip3를 사용하여 설치됩니다. 이를 위해서는 python3과 pip3가 설치되어 있어야 합니다. 설치하지 않은 경우 다음 명령을 실행할 수 있습니다.

sudo apt-get install libffi-dev libssl-dev
sudo apt install python3-dev
sudo apt-get install -y python3 python3-pip

python3 및 pip3이 설치되면 다음 명령을 사용하여 Docker-Compose를 설치할 수 있습니다.

sudo pip3 install docker-compose

 

1-5 Enable the Docker system service to start your containers on boot

이것은 매우 훌륭하고 중요한 추가 사항입니다. 다음 명령을 사용하여 부팅할 때마다 Docker 시스템 서비스를 자동으로 실행하도록 Raspberry Pi를 구성할 수 있습니다.

sudo systemctl enable docker

이를 사용하면 재시작 정책이 항상 또는 중지되지 않는 것으로 설정된 컨테이너는 재부팅 후 자동으로 다시 시작됩니다.

1-6 Run Hello World Container

Docker가 올바르게 설정되었는지 테스트하는 가장 좋은 방법은 Hello World 컨테이너를 실행하는 것입니다.
이렇게 하려면 다음 명령을 입력하십시오.

docker run hello-world

모든 단계를 거치면 출력에서 ​​설치가 올바르게 작동하는 것으로 나타납니다.

 

My docker version

1-7 A Sample Docker Compose file

이 섹션은 Docker-Compose 파일의 빠른 샘플을 보여줍니다. 이 샘플은 Raspberry Pi가 완전히 전원을 껐다 켜면 자동으로 시작되는 3개의 컨테이너를 시작합니다. 샘플 프로젝트에 대해 자세히 알아보려면 GitHub의 Docker 속도 테스트 프로젝트를 방문하세요.

version: '3'
services:
  # Tests the current internet connection speed
  # once per hour and writes the results into an
  # InfluxDB instance
  speedtest:    
    image: robinmanuelthiel/speedtest:0.1.1
    restart: always
    depends_on:
      - influxdb
    environment:
      - LOOP=true
      - LOOP_DELAY=3600 # Once per hour
      - DB_SAVE=true
      - DB_HOST=http://influxdb:8086
      - DB_NAME=speedtest
      - DB_USERNAME=admin
      - DB_PASSWORD=<MY_PASSWORD>

  # Creates an InfluxDB instance to store the
  # speed test results
  influxdb:
    image: influxdb
    restart: always
    volumes:
      - influxdb:/var/lib/influxdb
    ports:
      - "8083:8083"
      - "8086:8086"
    environment:
      - INFLUXDB_ADMIN_USER=admin
      - INFLUXDB_ADMIN_PASSWORD=<MY_PASSWORD>
      - INFLUXDB_DB=speedtest

  # Displays the results in a Grafana dashborad
  grafana:
    image: grafana/grafana:latest
    restart: always
    depends_on:
      - influxdb
    ports:
      - 3000:3000
    volumes:
      - grafana:/var/lib/grafana

volumes:
  grafana:
  influxdb:

Docker-Compose를 사용하여 컨테이너를 시작하려면 다음 명령을 실행합니다.

docker-compose -f docker-compose.yaml up -d

 

2 Find Raspberry PI Docker Images

Raspberry Pi는 ARM 아키텍처를 기반으로 합니다. 따라서 모든 Docker 이미지가 Raspberry Pi에서 작동하는 것은 아닙니다.
Docker Hub에서 가져올 이미지를 검색할 때 기억하십시오. 아키텍처 필터를 적용하여 지원되는 앱을 검색합니다.

 

 

3 How to Upgrade Docker on Raspberry Pi?

다음 명령과 함께 패키지 관리자를 사용하여 Docker를 업그레이드합니다.

sudo apt-get upgrade

4. How to Uninstall Docker on Raspberry PI?

패키지 관리자를 사용하여 도커를 간단히 제거할 수 있습니다.

sudo apt-get purge docker-ce

참고: 소프트웨어 버전에 따라 Docker를 완전히 제거하려면 추가 명령을 사용해야 할 수도 있습니다.

sudo apt-get purge docker-ce-cli

남은 이미지, 컨테이너, 볼륨 및 기타 관련 데이터를 삭제하려면 다음 명령을 실행합니다.

sudo rm -rf /var/lib/docker

 

참고사이트

https://phoenixnap.com/kb/docker-on-raspberry-pi

 

How to Install Docker on Rasberry Pi (Step-by-Step Guide)

In this SIMPLE Tutorial Learn How to Install Docker on a Raspberry Pi. Set up Docker in five (5) steps and start developing using containers.

phoenixnap.com

https://pumpingco.de/blog/setup-your-raspberry-pi-for-docker-and-docker-compose/

 

Setup your Raspberry Pi for Docker and Docker-Compose

Personally, I like to use Docker containers on my Raspberry Pis as they come with a great layer of abstraction and portability. Here is how to get your Raspberry Pi ready for Docker and Docker-Compose. 1. Setup your Raspberry Pi with Raspbian, Wifi and SSH

pumpingco.de

 

반응형