总是听人说在树莓派上使用docker多好多好,近日,自己推演了一番,发现的确不错,起码隔离效果挺好。要知道,树莓派由于是arm架构,所以更多pip包只能以apt python3-xxx的形式安装在系统里(用venv会各种错,安装错、使用时错,痛不欲生)。所以,就想试试用docker隔离,把我之前的[时序分解股票],做成微服务放上去。
sudo docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
sudo usermod -aG docker $USER
把用户加进docker组里,之后新终端里就不需要用sudo docker了。
FROM resin/rpi-raspbian:latest ENTRYPOINT [] RUN rm /etc/apt/sources.list COPY sources.list /etc/apt/sources.list RUN rm /etc/apt/sources.list.d/raspi.list COPY raspi.list /etc/apt/sources.list.d/raspi.list RUN apt update && \ apt upgrade RUN apt install libcurl4 RUN apt install apt-utils CMD ["/bin/bash"]
docker build -t zhangsheng377/raspberry_base .
若是上述dockerfile中没有加
> CMD ["/bin/bash"]
则需要在 docker run 时指定command:
docker run -ti zhangsheng377/raspberry_base /bin/bash
否则,只需:
docker run -ti zhangsheng377/raspberry_base
FROM zhangsheng377/raspberry_base ENTRYPOINT [] RUN apt update && \ apt upgrade CMD ["/bin/bash"]
docker build -t zhangsheng377/raspberry_base -f Dockerfile .
# docker run -d -p 5000:5000 --restart always zhangsheng377/stats_stock docker run -d -p 5000:5000 -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro --restart always zhangsheng377/stats_stock
其中: