创建一个脚本,用于安装必要组件和docker。以下是针对nano pi M1,使用的是H3芯片,因此docker用的源是arch=armhf,需要根据需求进行修改
#!/bin/bash
# 1. Update the system
sudo apt-get update && sudo apt-get upgrade -y
# 2. Install pip2 and pip3
sudo apt-get install python-pip python3-pip -y
# 3. Install Docker
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=armhf] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce -y
# Set Docker to start on boot
sudo systemctl enable docker
sudo systemctl start docker
# docker compose
sudo apt-get install libffi-dev libssl-dev -y
sudo apt-get install -y python3 python3-pip -y
sudo apt-get remove python-configparser -y
sudo pip3 install docker-compose
# 4. Install Portainer
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
# 5. Install other common tools
sudo apt-get install -y git vim htop net-tools
echo "Setup complete!"