서버/docker
DOCKER VOLUME mount/bind
iiliiiili
2021. 8. 27. 17:02
도커 볼륨 생성 및 바인드를 하지 않고 도커 재시작을 한다면..
그동안의 데이터가 모두 사라지는 재앙을 경험하게 될 것이다.
docker volume?
DOCKER BIND?
elastalert dockerfile
FROM alpine:latest as py-ea ARG ELASTALERT_VERSION=v0.2.0b2 ENV ELASTALERT_VERSION=${ELASTALERT_VERSION} # URL from which to download Elastalert. ARG ELASTALERT_URL=https://github.com/Yelp/elastalert/archive/$ELASTALERT_VERSION.zip ENV ELASTALERT_URL=${ELASTALERT_URL} # Elastalert home directory full path. ENV ELASTALERT_HOME /opt/elastalert WORKDIR /opt RUN apk add --update --no-cache ca-certificates openssl-dev openssl python2-dev python2 py2-pip py2-yaml libffi-dev gcc musl-dev wget && \ # Download and unpack Elastalert. wget -O elastalert.zip "${ELASTALERT_URL}" && \ unzip elastalert.zip && \ rm elastalert.zip && \ mv e* "${ELASTALERT_HOME}" WORKDIR "${ELASTALERT_HOME}" # Install Elastalert. # see: https://github.com/Yelp/elastalert/issues/1654 RUN sed -i 's/jira>=1.0.10/jira>=1.0.10,<1.0.15/g' setup.py && \ python setup.py install && \ pip install -r requirements.txt FROM node:alpine LABEL maintainer="BitSensor <dev@bitsensor.io>" # Set timezone for this container ENV TZ Etc/UTC RUN apk add --update --no-cache curl tzdata python2 make libmagic COPY --from=py-ea /usr/lib/python2.7/site-packages /usr/lib/python2.7/site-packages COPY --from=py-ea /opt/elastalert /opt/elastalert COPY --from=py-ea /usr/bin/elastalert* /usr/bin/ WORKDIR /opt/elastalert-server COPY . /opt/elastalert-server RUN npm install --production --quiet COPY config/elastalert.yaml /opt/elastalert/config.yaml COPY config/elastalert-test.yaml /opt/elastalert/config-test.yaml COPY config/config.json config/config.json COPY rule_templates/ /opt/elastalert/rule_templates COPY elastalert_modules/ /opt/elastalert/elastalert_modules # Add default rules directory # Set permission as unpriviledged user (1000:1000), compatible with Kubernetes RUN mkdir -p /opt/elastalert/rules/ /opt/elastalert/server_data/tests/ \ && chown -R node:node /opt USER node EXPOSE 3030 ENTRYPOINT ["npm", "start"] |
#docker volume create [볼륨명]
# docker volume ls
- 생성되었는지 확인
# docker run -it --name [컨테이너명] -v /절대경로:/[볼륨명] [이미지:버전]
ex) docker run -it --name -elastalert -v /data/elastalert:/ELASTALERT elastalert:latest
1. volume 추가
2.