#!/bin/bash # Uninstall all conflicting packages: for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do apt-get remove $pkg; done # Add Docker's official GPG key: apt-get update && apt-get dist-upgrade -y && apt-get autoremove -y && apt-get install -y ca-certificates curl openssl install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc chmod a+r /etc/apt/keyrings/docker.asc # Add the repository to Apt sources: echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin echo && echo "$(docker -v) foi instalado com sucesso!" && echo mkdir /etc/ssl/portainer openssl req -x509 \ -nodes \ -days 3650 \ -newkey rsa:2048 \ -keyout /etc/ssl/portainer/portainer.key \ -out /etc/ssl/portainer/portainer.crt \ -subj "/C=BR/ST=RJ/L=Rio de Janeiro/O=Portal Aprendendo Linux/OU=TI/CN=Henrique Fagundes/emailAddress=henrique@aprendendolinux.com" cat > /root/docker-compose.yml << 'EOF' networks: minha-rede: driver: bridge name: minha-rede services: portainer: container_name: portainer hostname: portainer ## Imagem versao da comunidade image: portainer/portainer-ce:sts ## Caso queira a versao Bussines use essa imagem # image: portainer/portainer-ee:latest networks: - minha-rede restart: always volumes: - /var/run/docker.sock:/var/run/docker.sock - /srv/portainer:/data - /etc/ssl/portainer:/certs # - /srv/proxy/letsencrypt/live:/srv/proxy/letsencrypt/live # - /srv/proxy/letsencrypt/archive:/srv/proxy/letsencrypt/archive ports: - "60022:9443" command: --sslcert /certs/portainer.crt --sslkey /certs/portainer.key # --sslcert /srv/proxy/letsencrypt/live/npm-XXX/cert.pem # --sslkey /srv/proxy/letsencrypt/live/npm-XXX/privkey.pem EOF cat >> /root/.bashrc << 'EOF' alias list='docker ps -a --format "{{.ID}} : {{.State}} : {{.Status}} : {{.Names}}"' EOF docker compose -f /root/docker-compose.yml --project-name portainer up -d echo && echo 'Acesse https://seu-endereco-ip:60022'