.png)
나는 이것이 쉬운 것이기를 바랍니다. 저는 Docker를 사용하여 Raspberry Pi 4에서 Homeassistant 및 Node-Red 컨테이너를 실행하고 있습니다.
기반이 가이드그들은 Homeassistant를 지원하기 위해 Node-Red 노드를 설치하기 위해 DockerFile을 만드는 것을 권장합니다. 설치는 npm
Node-Red 컨테이너 내의 명령을 통해 처리됩니다.
나는 디렉토리에 docker-compose.yaml
및 둘 다 생성했습니다.Dockerfile
(아래 파일 내용).
컨테이너를 부팅하려면 파일이 docker-compose up
있는 디렉터리에서 명령을 사용합니다 docker-compose.yaml
. 또한 문제 없이 동일한 작업을 수행하는 시스템 서비스도 만들었습니다.
내 문제는 DockerFile
내가 실행할 때 처리되지 않는다는 것입니다docker-compose up
컨테이너가 시작/다시 시작될 때마다 docker-compose
변경 사항을 선택하는 방법이 있습니까 ?DockerFile
[docker-compose.yaml]
version: "3.6"
services:
node-red:
build: .
container_name: node-red
environment:
TZ: /etc/localtime
image: nodered/node-red
restart: unless-stopped
ports:
- "1880:1880"
volumes:
- "/[folders]/node-red/data:/data"
[DockerFile]
FROM nodered/node-red
RUN npm install node-red-contrib-actionflows \
# https://flows.nodered.org/node/node-red-contrib-actionflows
node-red-contrib-home-assistant-websocket \
# https://flows.nodered.org/node/node-red-contrib-home-assistant-websocket
node-red-contrib-stoptimer \
# https://flows.nodered.org/node/node-red-contrib-stoptimer
node-red-contrib-time-range-switch \
# A simple Node-RED node that routes messages depending on the time. If the current time falls within the range specified in the node configuration, the message is routed to output 1. Otherwise the message is routed to output 2.
node-red-contrib-timecheck \
# Is it that time yet? This node compares a given time to the current time.
node-red-node-timeswitch
# node to provide a simple timeswitch node to schedule daily on/off events
답변1
방금 몇 가지 간단한 테스트를 수행했는데 여기에 두 가지 문제가 있다고 생각합니다. 하나는 간단하고 다른 하나는 실제로 매우 미묘합니다.
첫 번째 문제는 이미지가 이미 존재하는 경우 Compose가 서비스 이미지를 자동으로 다시 빌드하지 않는다는 것입니다. 서비스를 처음 실행하면 Compose는 dockerfile을 사용하여 이미지를 빌드하지만 후속 실행에서는 기존 이미지를 다시 사용합니다.문서docker-compose up
실제로 이에 대해 실망스러울 정도로 명확하지 않지만 샘플 파일에서 실행할 때의 명령 출력이 더 유용합니다.
...
WARNING: Image for service node-red was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
...
나는 당신이 찾고 있는 동작을 얻으려면 --build
동일한 태그가 있는 이미지의 존재 여부에 관계없이 재구축을 트리거하는 플래그를 사용하도록 systemd 서비스를 수정해야 한다고 믿습니다.
제가 겪고 있는 두 번째 문제(이 역시 수정된 샘플 구성 버전을 사용하여 실행한 빠른 테스트를 기반으로 함)는 각 빌드에서 기본 이미지 태그를 덮어쓰고 있다는 것입니다.
지시어 의 Compose 파일 참조 섹션에 따르면 build
(아래의 세 번째 블록)이 링크) 및 둘 다 build
서비스 image
에 지정되면 docker는 빌드 지시문에 따라 이미지를 빌드한 다음 image 지시문의 값을 사용하여 태그를 지정합니다. image
docker-compose 파일의 지시문과 dockerfile FROM
의 지시문은 동일한 태그를 사용하므로 Docker는 dockerfile이 가져오는 기본 이미지와 동일한 이름으로 로컬로 빌드된 이미지에 태그를 지정하도록 지시합니다.
nodered/node-red
이는 컨테이너를 다시 빌드할 때마다(첫 번째 빌드 이후) 실제로 업스트림의 컨테이너를 사용하는 대신 이전 버전 자체를 기본 컨테이너로 사용한다는 의미입니다 .
image
이 문제를 해결하려면 작성 파일의 지시어 값을 다른 것으로 변경하세요 . 예를 들어local-custom-node-red