Portainer News and Blog

Managing your local Docker instance as an edge device with Portainer

Written by Neil Cresswell, CEO | September 12, 2022

**** UPDATED APRIL 2022 - Confirmed still working. Note that the Agent must use the same version as the Portainer Server (at time of update, 2.18.1) ****

So you have a standalone Docker host, but you want to experiment with Portainer's Edge Compute features. Or maybe you just want to use one of the features on your local machine (eg Edge Jobs, to schedule tasks to run on the host). Read on to learn how this can be achieved.

This can be accomplished using Portainer but is a non-standard deployment. Let me show you how:

Step 1, Deploy the Portainer Server instance. Note, you do not need to bind mount the docker socket, so the install command is just:

docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v portainer_data:/data portainer/portainer-ce:latest

Do this, and then log into Portainer, set your initial admin password,

Now click on "Add Environments"

Click on "Docker", then "start wizard"

Click on "edge agent"

Enter a name for the environment, eg local, and then in the URL put in https://host.docker.internal:9443 and click "create"

Click on "Docker standalone" and then copy the script

Paste into a text editor, and adjust, adding in the text in BOLD so it looks something like this:

docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/lib/docker/volumes:/var/lib/docker/volumes \
-v /:/host \
-v portainer_agent_data:/data \
--restart always \
-e EDGE=1 \
-e EDGE_ID=6e0a2378-324f-43c2-9a96-43594fcf9737 \
-e EDGE_KEY=aHR0cHM6Ly9ob3N0LmRvY2tlci5pbnRlcm5hbDo5NDQzfGhvc3QuZG9ja2VyLmludGVybmFsOjgwMDB8OTE6NzA6MjY6Zjg6ZmQ6Mzg6ZjA6Nzc6MDU6ZTU6MjY6YjY6N2I6YWY6Y2U6YmR8Mw \
-e EDGE_INSECURE_POLL=1 \
--name portainer_edge_agent \
--add-host=host.docker.internal:host-gateway \
portainer/agent:latest

Paste this into your CLI window, and it will start the agent.

Go back into Portainer and click "close"

Note your Environment is added, and it has a green heartbeat.

You can click on it, to manage that host.

Now, if you want to use the Edge features, click on settings, Edge Compute, and enable edge compute features.

You can now use Edge Jobs to schedule tasks on that host (as an example).

That's how easy it is to deploy the Edge Agent on your local Docker-CE Instance.