Portainer Installation Guide on Docker
A step-by-step guide to installing Portainer on your Docker host. This guide covers two methods: a simple Docker CLI command and a more robust Docker Compose file. Portainer simplifies managing your Docker containers, images, and volumes through a user-friendly web interface.
Step 1: Brief Introduction to Portainer
Portainer is a lightweight management user interface for Docker. It allows you to easily manage your Docker environments, including containers, images, networks, and volumes, without needing to use the command line. It's an essential tool for beginners and a great time-saver for experienced users.
Step 2: Create a Docker Volume
Before you run the container, it's a best practice to create a dedicated Docker volume to store Portainer's persistent data. This ensures your configuration and settings are not lost if the container is removed or updated.
docker volume create portainer_data
Step 3: Option 1: Install with Docker CLI
This is the quickest way to get Portainer up and running. The following command will download the latest Portainer image and run it as a detached container. It maps port 9000 for the web UI and mounts the `portainer_data` volume and the Docker socket.
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:latest
Step 4: Option 2: Install with Docker Compose
For a more declarative and repeatable approach, you can use Docker Compose. Create a new file named `docker-compose.yml` and paste the following content into it. This method makes it easy to manage your Portainer container alongside other services.
version: '3.9'
services:
portainer:
container_name: portainer
image: portainer/portainer-ce:latest
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
ports:
- '9000:9000'
- '8000:8000'
volumes:
portainer_data:
driver: local
Once the file is saved, run the following command in the same directory to start the container.
docker-compose up -d
Step 5: Access the Portainer UI
After the container is running, you can access the Portainer web interface by opening a web browser and navigating to your server's IP address on port 9000. For example: `http://your_server_ip:9000`
Step 6: Initial Portainer Setup
On your first visit, you'll be prompted to create an administrator user and password. Follow the on-screen instructions. Once completed, you will be able to connect to your local Docker environment and start managing your containers.
Step 7: Add External Templates
From the Portainer dashboard, navigate to **Settings**. Scroll down to the **Templates** section and paste the external template URL into the designated field. Then click 'Save settings'.
https://raw.githubusercontent.com/Lissy93/portainer-templates/main/templates_v3.json
Step 8: Access the New Templates
After saving, go to **App Templates** in the left-hand navigation pane. The newly imported templates will now be available for quick deployment, expanding your options for services and applications.
Step 9: Clean Up (Optional)
If you need to remove the Portainer container and its volume, you can use these commands. Be aware that this will permanently delete your Portainer configuration and data.
docker rm -f portainer && docker volume rm portainer_data