Created
November 16, 2025 17:53
-
-
Save alexolinux/b2c462f3fe0be2de558eed3453bbdcab to your computer and use it in GitHub Desktop.
Docker Agent for Portainer Environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #https://hub.docker.com/r/portainer/agent | |
| AGENT_VERSION="2.33.3-alpine" | |
| # Check if the script is being run as root. | |
| if [ "$(id -u)" -eq 0 ]; then | |
| echo "This script should not be run as root. Run it as a non-root user." | |
| exit 1 | |
| fi | |
| # Verifica se o Docker está instalado e em execução | |
| if ! command -v docker &> /dev/null; then | |
| echo "Docker is not installed. Please install Docker before running this script." | |
| exit 1 | |
| fi | |
| if ! systemctl is-active --quiet docker; then | |
| echo "The Docker service is not running. Start Docker and try again." | |
| exit 1 | |
| fi | |
| # Executa o comando Docker | |
| docker run -d \ | |
| -p 9001:9001 \ | |
| --name portainer_agent \ | |
| --restart=always \ | |
| -v /var/run/docker.sock:/var/run/docker.sock \ | |
| -v /var/lib/docker/volumes:/var/lib/docker/volumes \ | |
| -v /:/host \ | |
| portainer/agent:${AGENT_VERSION} | |
| # Verifica se o comando foi bem-sucedido | |
| if [ $? -eq 0 ]; then | |
| echo "Portainer Agent started successfully." | |
| echo "You can check the Portainer Agent Logs: docker logs portainer_agent" | |
| else | |
| echo "Failed starting Portainer Agent." | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment