라즈베리파이 Docker + Portainer 설치

박현민·2022년 3월 11일
0

라즈베리파이

목록 보기
1/4

Home Assistant OS가 설치된 라즈베리파이가 있지만 Home Assistant외 다른 용도로는 사용할 수 없기때문에 요번에는 Docker를 사용하여 Home Assistant를 설치해보고자 한다.


1. 시스템 업데이트
업데이트/업그레이드를 한다

sudo apt update
sudo apt upgrade

2. Docker 설치
curl -fsSL https://get.docker.com -o get-docker.sh //스크립트 다운
sudo sh get-docker.sh //스크립트 실행

역시 오류를 내면서 한번에 설치되지 않았다.

pi@raspberrypi:~ $ sudo sh get-docker.sh 
# Executing docker install script, commit: 93d2499759296ac1f9c510605fef85052a2c32be
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c curl -fsSL "https://download.docker.com/linux/raspbian/gpg" | gpg --dearmor --yes -o /usr/share/keyrings/docker-archive-keyring.gpg
+ sh -c echo "deb [arch=armhf signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/raspbian bullseye stable" > /etc/apt/sources.list.d/docker.list
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends  docker-ce-cli docker-ce >/dev/null
E: Sub-process /usr/bin/dpkg returned an error code (1)

그래서 다시 apt update와 apt upgrade를 한후 스크립트를 다시 실행하니 설치가 되었다.

pi@raspberrypi:~ $ sudo sh get-docker.sh 
# Executing docker install script, commit: 93d2499759296ac1f9c510605fef85052a2c32be
Warning: the "docker" command appears to already exist on this system.

If you already have Docker installed, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation.

If you installed the current Docker package using this script and are using it
again to update Docker, you can safely ignore this message.

You may press Ctrl+C now to abort this script.
+ sleep 20
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c curl -fsSL "https://download.docker.com/linux/raspbian/gpg" | gpg --dearmor --yes -o /usr/share/keyrings/docker-archive-keyring.gpg
+ sh -c echo "deb [arch=armhf signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/raspbian bullseye stable" > /etc/apt/sources.list.d/docker.list
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends  docker-ce-cli docker-ce >/dev/null
+ version_gte 20.10
+ [ -z  ]
+ return 0
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce-rootless-extras >/dev/null
+ sh -c docker version
Client: Docker Engine - Community
Version:           20.10.13
API version:       1.41
Go version:        go1.16.15
Git commit:        a224086
Built:             Thu Mar 10 14:08:00 2022
OS/Arch:           linux/arm
Context:           default
Experimental:      true

Server: Docker Engine - Community
Engine:
 Version:          20.10.13
 API version:      1.41 (minimum version 1.12)
 Go version:       go1.16.15
 Git commit:       906f57f
 Built:            Thu Mar 10 14:05:56 2022
 OS/Arch:          linux/arm
 Experimental:     false
containerd:
 Version:          1.5.10
 GitCommit:        2a1d4dbdb2a1030dc5b01e96fb110a9d9f150ecc
runc:
 Version:          1.0.3
 GitCommit:        v1.0.3-0-gf46b6ba
docker-init:
 Version:          0.19.0
 GitCommit:        de40ad0

================================================================================

To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:

   dockerd-rootless-setuptool.sh install

Visit https://docs.docker.com/go/rootless/ to learn about rootless mode.


To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to https://docs.docker.com/go/daemon-access/

WARNING: Access to the remote API on a privileged Docker daemon is equivalent
        to root access on the host. Refer to the 'Docker daemon attack surface'
        documentation for details: https://docs.docker.com/go/attack-surface/

================================================================================


3. 권한 설정 pi 계정에서도 root권한 없이 docker를 실행할 수 있게 docker그룹에 pi를 추가해야한다
sudo usermod -aG docker pi

재부팅해주면 적용된다


4. 부팅시 실행 지정

sudo systemctl enable docker




다음은 Portainer설치이다.
도커를 관리하는데 유용한 프로그램이라 한다.

sudo docker run -d --restart=always --name=portainer -p 9000:9000\
-v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data\
portainer/portainer-ce:latest

출처 : 라즈베리파이로 IoT 만들기 - 2편, Docker 로 프로그램 설치하기|작성자 레이

0개의 댓글