Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to retrieve local agent IP address with agent 1.5.0 #95

Closed
svengo opened this issue Oct 11, 2019 · 32 comments · Fixed by #97
Closed

Unable to retrieve local agent IP address with agent 1.5.0 #95

svengo opened this issue Oct 11, 2019 · 32 comments · Fixed by #97
Assignees
Labels
bug Something isn't working
Milestone

Comments

@svengo
Copy link

svengo commented Oct 11, 2019

After updating to agent 1.5.0 I only get error messages:

portainer_agent_1  | 2019/10/11 06:40:19 [ERROR] [main,docker] [message: Unable to retrieve local agent IP address] [error: unable to retrieve the address on which the agent can advertise. Check your network settings]

I am running agent from docker-compose using the following docker-compose.yml:

version: '2.3'

services:
  portainer_agent:
    image: "portainer/agent:1.5.0"
    ports:
      - "9001:9001"
    userns_mode: "host"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /mnt/docker/volumes:/var/lib/docker/volumes
      - ${MY_VOLUME_PATH}/admin_portainer_agent/:/data
    restart: "${RESTART:-unless-stopped}"

System environment:

sven@fangorn:~$ uname -a
Linux fangorn 5.0.0-31-generic #33~18.04.1-Ubuntu SMP Tue Oct 1 10:20:39 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
sven@fangorn:~$ docker version
Client: Docker Engine - Community
 Version:           19.03.3
 API version:       1.40
 Go version:        go1.12.10
 Git commit:        a872fc2f86
 Built:             Tue Oct  8 00:59:59 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.3
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.10
  Git commit:       a872fc2f86
  Built:            Tue Oct  8 00:58:31 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
sven@fangorn:~$ docker-compose version
docker-compose version 1.24.1, build 4667896b
docker-py version: 3.7.3
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.1.0j  20 Nov 2018
@tkw1536
Copy link

tkw1536 commented Oct 11, 2019

Same problem here, 1.5 just produces an error whereas 1.4 works perfectly fine.
I have also tried directly running the command produced by the Web UI:

  docker run -d -v /var/run/docker.sock:/var/run/docker.sock \
              -v /var/lib/docker/volumes:/var/lib/docker/volumes \
              -v /:/host \
              --restart always \
              -e EDGE=1 \
              -e EDGE_ID=000000000-0000-0000-0000-000000000000 \
              -e CAP_HOST_MANAGEMENT=1 \
              -p 8000:80 \
              -v portainer_agent_data:/data \
              --name portainer_edge_agent \
              portainer/agent

(Note: I've censored the edge ID)

I believe the problem is related to this line, in particular networkInspect.Scope != "swarm" seems to assume that the container is running inside a docker swarm.

@volschin
Copy link

Same problem on linux/arm.

@UniverseXXX
Copy link

I have tried the 1.5.1 version, however, unfortunately the bug is still present. The same error is still being thrown.

@deviantony
Copy link
Member

deviantony commented Oct 21, 2019

@UniverseXXX please share the logs of the Portainer agent with us and give us more information about the platform where the agent is running.

@UniverseXXX
Copy link

UniverseXXX commented Oct 22, 2019

@deviantony

│   2019/10/22 10:47:04 [INFO] [main] [message: Agent running on a Swarm cluster node. Running in cluster mode]                                      │
│   2019/10/22 10:47:04 [ERROR] [main,docker] [message: Unable to retrieve local agent IP address] [error: unable to retrieve the address on which   │
│    the agent can advertise. Check your network settings]  

Ubuntu 19.10 x86_64 /Linux ubuntu 5.3.0-19-generic/
Docker version 19.03.2, build 6a30dfca03

Portainer-Agent-FRW:
    image:          "portainer/agent:1.5.1"
    container_name: "Portainer-Agent-FRW"
    restart:        always
    networks:
      raf:
        ipv4_address: 192.168.1.134
    deploy:
     mode: global
     placement:
        constraints: [node.platform.os == linux]
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /var/lib/docker/volumes:/var/lib/docker/volumes
    environment:
      - TZ=Europe/London
      - AGENT_CLUSTER_ADDR=192.168.1.134
      - CAP_HOST_MANAGEMENT=true

@deviantony
Copy link
Member

@UniverseXXX can you start the agent with debug logs enabled? Add the following environment variable to your stack file:

LOG_LEVEL=debug

Also, can you share the ENTIRE logs with us? Thanks

@UniverseXXX
Copy link

@deviantony Here is the log:

│   2019/10/23 07:31:58 [DEBUG] [docker] [network_name: raf] [scope: local] [ingress: false] [message: Skipping invalid container network]           │
│   2019/10/23 07:31:58 [ERROR] [main,docker] [message: Unable to retrieve local agent IP address] [error: unable to retrieve the address on which   │
│    the agent can advertise. Check your network settings]                                                                                           │
│   2019/10/23 07:32:00 [DEBUG] [main,configuration] [Member tags: map[AgentPort:9001 EngineStatus:swarm NodeName:ubuntu NodeRole:manager]]          │
│   2019/10/23 07:32:00 [INFO] [main] [message: Agent running on a Swarm cluster node. Running in cluster mode]   

and perhaps, it would be useful, here is how network is being declared:

networks:
  raf:
    name: raf
    driver: macvlan
    driver_opts:
      parent: ens18
    ipam:
      config:
        - subnet: 192.168.1.0/24

Thanks.

@deviantony
Copy link
Member

@UniverseXXX thanks. When I meant the ENTIRE logs, entire logs would be nice to have. Just to ensure that you are correctly running the latest version and that allow us to avoid making assumptions.

2019/10/23 22:31:56 [INFO] [http] [server_addr: 0.0.0.0] [server_port: 9001] [secured: true] [api_version: 1.5.1] [message: Starting Agent API server]

Anyway, I assume that you're running the agent inside a Swarm over a macvlan network?

@UniverseXXX
Copy link

@deviantony Thanks for the reply. Yes, it's running over a macvlan network.

@Svedrin
Copy link

Svedrin commented Oct 28, 2019

Happens to me as well. I'm trying to use the Edge agent as an alternative to connecting directly to the Docker agent, which would require having to maintain an internal TLS PKI. The node is a standalone AWS EC2 instance with Docker installed. I'm running the command as given by the Web UI, edited only to disable autorestart (because the Agent exits anyway) and enable debug logging:

# docker run -d -v /var/run/docker.sock:/var/run/docker.sock \
              -v /var/lib/docker/volumes:/var/lib/docker/volumes \
              -v /:/host \
              -e EDGE=1 \
              -e EDGE_ID=<uuid> \
              -e LOG_LEVEL=debug \
              -e CAP_HOST_MANAGEMENT=1 \
              -p 8000:80 \
              -v portainer_agent_data:/data \
              --name portainer_edge_agent \
              portainer/agent

The node only has the default Docker networks:

# docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
c350d11f2317        bridge              bridge              local
bd69180f43cb        host                host                local
9daed959a124        none                null                local

Here's the log output from Portainer agent:

2019/10/28 10:26:20 [DEBUG] [main,configuration] [Member tags: map[AgentPort:9001 EngineStatus:standalone NodeName:ip-172-21-4-79]]
2019/10/28 10:26:20 [DEBUG] [docker] [network_name: bridge] [scope: local] [ingress: false] [message: Skipping invalid container network]
2019/10/28 10:26:20 [ERROR] [main,docker] [message: Unable to retrieve local agent IP address] [error: unable to retrieve the address on which the agent can advertise. Check your network settings]

@Svedrin
Copy link

Svedrin commented Oct 28, 2019

Actually, scratch that: It appears I had already pulled the portainer/agent image two weeks back, and it ran on 1.5.0. If I explicitly pull the 1.5.1 tag and run from it, it starts up just fine.

Sorry for the noise.

@nemchik
Copy link

nemchik commented Oct 28, 2019

I'm having the issue. Here's my compose:

version: '3.4'
services:
  portaineragent:
    container_name: portaineragent
    environment:
      CAP_HOST_MANAGEMENT: '1'
      LOG_LEVEL: debug
      TZ: America/Chicago
    image: portainer/agent
    logging:
      driver: json-file
      options:
        max-file: '10'
        max-size: 200k
    ports:
    - published: 9001
      target: 9001
    restart: unless-stopped
    volumes:
    - /etc/localtime:/etc/localtime:ro
    - /:/host:rw
    - /home/gibbs/.config/appdata/shared:/shared:rw
    - /var/lib/docker/volumes:/var/lib/docker/volumes:rw
    - /var/run/docker.sock:/var/run/docker.sock:rw

Here's the output of docker ps

CONTAINER ID        IMAGE                   COMMAND                 CREATED             STATUS                          PORTS
                                                                                                                          NAMES
fd319d85d22a        portainer/agent         "./agent"               7 minutes ago       Restarting (1) 24 seconds ago
                                                                                                                          portaineragent

Here is the output of docker inspect portaineragent

[
    {
        "Id": "fd319d85d22a8f72a8ab2cbc7a11632dab15c36b6e9e9a54bd0396510e92cad3",
        "Created": "2019-10-28T17:03:03.485344308Z",
        "Path": "./agent",
        "Args": [],
        "State": {
            "Status": "exited",
            "Running": false,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 0,
            "ExitCode": 1,
            "Error": "",
            "StartedAt": "2019-10-28T17:34:31.10567086Z",
            "FinishedAt": "2019-10-28T17:34:31.175511934Z"
        },
        "Image": "sha256:601a011ddd8b56a001dc5795aa39491d2129d323b19d649d7b75bacd903bfb3f",
        "ResolvConfPath": "/var/lib/docker/containers/fd319d85d22a8f72a8ab2cbc7a11632dab15c36b6e9e9a54bd0396510e92cad3/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/fd319d85d22a8f72a8ab2cbc7a11632dab15c36b6e9e9a54bd0396510e92cad3/hostname",
        "HostsPath": "/var/lib/docker/containers/fd319d85d22a8f72a8ab2cbc7a11632dab15c36b6e9e9a54bd0396510e92cad3/hosts",
        "LogPath": "/var/lib/docker/containers/fd319d85d22a8f72a8ab2cbc7a11632dab15c36b6e9e9a54bd0396510e92cad3/fd319d85d22a8f72a8ab2cbc7a11632dab15c36b6e9e9a54bd0396510e92cad3-json.log",
        "Name": "/portaineragent",
        "RestartCount": 40,
        "Driver": "aufs",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/:/host:rw",
                "/etc/localtime:/etc/localtime:ro",
                "/var/run/docker.sock:/var/run/docker.sock:rw",
                "/var/lib/docker/volumes:/var/lib/docker/volumes:rw",
                "/home/gibbs/.config/appdata/shared:/shared:rw"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {
                    "max-file": "10",
                    "max-size": "200k"
                }
            },
            "NetworkMode": "compose_default",
            "PortBindings": {
                "9001/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "9001"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "unless-stopped",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "CapAdd": null,
            "CapDrop": null,
            "Capabilities": null,
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": null,
            "Name": "aufs"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/etc/localtime",
                "Destination": "/etc/localtime",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/var/run/docker.sock",
                "Destination": "/var/run/docker.sock",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/var/lib/docker/volumes",
                "Destination": "/var/lib/docker/volumes",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rslave"
            },
            {
                "Type": "bind",
                "Source": "/home/gibbs/.config/appdata/shared",
                "Destination": "/shared",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/",
                "Destination": "/host",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rslave"
            }
        ],
        "Config": {
            "Hostname": "fd319d85d22a",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "9001/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "CAP_HOST_MANAGEMENT=1",
                "TZ=America/Chicago",
                "LOG_LEVEL=debug",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": null,
            "Image": "portainer/agent",
            "Volumes": {
                "/etc/localtime": {},
                "/host": {},
                "/shared": {},
                "/var/lib/docker/volumes": {},
                "/var/run/docker.sock": {}
            },
            "WorkingDir": "/app",
            "Entrypoint": [
                "./agent"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "e64ad14a7ad1b2cbd0cf40de106b5eaed9a0c7b454ceef03a484e83381fc5a98",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "compose",
                "com.docker.compose.service": "portaineragent",
                "com.docker.compose.version": "1.24.0"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "5dfdd94c74e31bf74538c653a9b85afafb507b89b388a62c5a2be9c9aede8d05",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/5dfdd94c74e3",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "compose_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "fd319d85d22a",
                        "portaineragent"
                    ],
                    "NetworkID": "217a6d2fd8cac38404c4da14da1014f819b26929ba3c6fbe27b8345f0eba40c1",
                    "EndpointID": "",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "",
                    "DriverOpts": null
                }
            }
        }
    }
]

Here's my docker logs portaineragent

2019/10/28 17:03:04 [DEBUG] [main,configuration] [Member tags: map[AgentPort:9001 EngineStatus:standalone NodeName:dumont]]
2019/10/28 17:03:04 [DEBUG] [docker] [network_name: compose_default] [scope: local] [ingress: false] [message: Skipping invalid container network]
2019/10/28 17:03:04 [ERROR] [main,docker] [message: Unable to retrieve local agent IP address] [error: unable to retrieve the address on which the agent can advertise. Check your network settings]

(these same 3 lines just repeat infinitely)

The compose_default network it is referencing is the network that docker-compose joins containers to when no network is assigned but ports are used in the compose. It is a user defined bridge network. The name of the network is based on the folder, ex: foldername_default so in my case my docker-compose.yml file is in a folder named compose and the resulting network is compose_default.

edit: added docker inspect

@deviantony
Copy link
Member

@nemchik please pull the latest version of the agent.

@deviantony
Copy link
Member

deviantony commented Oct 28, 2019

@UniverseXXX interesting, we did not test this use case. I think that the latest version of the agent is not compatible with macvlan in a Swarm as the macvlan network is not tagged as a swarm scoped.

EDIT: I'll re-open the issue and rename it to track this evolution.

@deviantony deviantony reopened this Oct 28, 2019
@deviantony deviantony changed the title Unable to retrieve local agent IP address with agent 1.5.0 Support deployment in Swarm cluster with macvlan network Oct 28, 2019
@deviantony deviantony added the enhancement New feature or request label Oct 28, 2019
@nemchik
Copy link

nemchik commented Oct 28, 2019

I stopped and rm'd the container, and pruned the image, and then ran compose again (same compose I posted above) which showed the latest image was pulled. It's still giving me the same error in the docker logs.

I have tried some docker exec commands in attempts to get the container to at least spit out the version of the agent inside, but the best i can do is grab docker inspect which i posted above.

Here is the output of docker inspect portainer/agent (inspecting the image)

[
    {
        "Id": "sha256:601a011ddd8b56a001dc5795aa39491d2129d323b19d649d7b75bacd903bfb3f",
        "RepoTags": [
            "portainer/agent:latest"
        ],
        "RepoDigests": [
            "portainer/agent@sha256:06f1244d67c258218eb577db761b269e95b9f2c877d9b3b9022aca3d0c4ba306"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2019-10-10T22:08:07.931357616Z",
        "Container": "046241ac4ea49c372141a615e49096e29bdd65aee2b798e5098a7542ff7ce145",
        "ContainerConfig": {
            "Hostname": "046241ac4ea4",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "ENTRYPOINT [\"./agent\"]"
            ],
            "Image": "sha256:7e8549cf7afcd22a8ec3cc01abb24b19ef35a26726443154d22ecccc99fa7dab",
            "Volumes": null,
            "WorkingDir": "/app",
            "Entrypoint": [
                "./agent"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "DockerVersion": "19.03.2",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": null,
            "Image": "sha256:7e8549cf7afcd22a8ec3cc01abb24b19ef35a26726443154d22ecccc99fa7dab",
            "Volumes": null,
            "WorkingDir": "/app",
            "Entrypoint": [
                "./agent"
            ],
            "OnBuild": null,
            "Labels": null
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 13918342,
        "VirtualSize": 13918342,
        "GraphDriver": {
            "Data": null,
            "Name": "aufs"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:dd4969f97241b9aefe2a70f560ce399ee9fa0354301c9aef841082ad52161ec5",
                "sha256:ddb8df5a6197bb07a99f4d21fbd95e9dc8a47b51277bd7c6bdc9fb07aaf149b8",
                "sha256:4b3e31b7e84051ca299e0a81bb2cceb167c11eedec073cfd5c937a20f54997b9",
                "sha256:809d262ed716f79a8b65b7910ad875152cae32525ede39756087a4a0ca716fe3"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]
[
    {
        "Id": "sha256:601a011ddd8b56a001dc5795aa39491d2129d323b19d649d7b75bacd903bfb3f",
        "RepoTags": [
            "portainer/agent:latest"
        ],
        "RepoDigests": [
            "portainer/agent@sha256:06f1244d67c258218eb577db761b269e95b9f2c877d9b3b9022aca3d0c4ba306"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2019-10-10T22:08:07.931357616Z",
        "Container": "046241ac4ea49c372141a615e49096e29bdd65aee2b798e5098a7542ff7ce145",
        "ContainerConfig": {
            "Hostname": "046241ac4ea4",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "ENTRYPOINT [\"./agent\"]"
            ],
            "Image": "sha256:7e8549cf7afcd22a8ec3cc01abb24b19ef35a26726443154d22ecccc99fa7dab",
            "Volumes": null,
            "WorkingDir": "/app",
            "Entrypoint": [
                "./agent"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "DockerVersion": "19.03.2",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": null,
            "Image": "sha256:7e8549cf7afcd22a8ec3cc01abb24b19ef35a26726443154d22ecccc99fa7dab",
            "Volumes": null,
            "WorkingDir": "/app",
            "Entrypoint": [
                "./agent"
            ],
            "OnBuild": null,
            "Labels": null
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 13918342,
        "VirtualSize": 13918342,
        "GraphDriver": {
            "Data": null,
            "Name": "aufs"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:dd4969f97241b9aefe2a70f560ce399ee9fa0354301c9aef841082ad52161ec5",
                "sha256:ddb8df5a6197bb07a99f4d21fbd95e9dc8a47b51277bd7c6bdc9fb07aaf149b8",
                "sha256:4b3e31b7e84051ca299e0a81bb2cceb167c11eedec073cfd5c937a20f54997b9",
                "sha256:809d262ed716f79a8b65b7910ad875152cae32525ede39756087a4a0ca716fe3"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

Is it possible that there's something wrong with the latest tag?

@nemchik
Copy link

nemchik commented Oct 28, 2019

Just for extra info i pulled portainer/agent:1.5.1 and it works no problem.

gibbs@dumont:~$ docker-compose up -d
Pulling portaineragent (portainer/agent:1.5.1)...
1.5.1: Pulling from portainer/agent
d1e017099d17: Already exists
4aec77405d0d: Pull complete
129bd2930e33: Pull complete
71e6dda38d0d: Pull complete
Digest: sha256:88989d2dd0783524ab5af4bb8f4f4be2ac82c10188e17c6c6bda862bb7a5676d
Status: Downloaded newer image for portainer/agent:1.5.1
Recreating portaineragent ...
Recreating portaineragent ... done


gibbs@dumont:~$ docker logs portaineragent
2019/10/28 20:28:03 [DEBUG] [main,configuration] [Member tags: map[AgentPort:9001 EngineStatus:standalone NodeName:dumont]]
2019/10/28 20:28:03 [DEBUG] [docker] [ip_address: 172.19.0.5] [network_name: compose_default] [message: Retrieving IP address from container network]
2019/10/28 20:28:04 [INFO] [http] [server_addr: 0.0.0.0] [server_port: 9001] [secured: true] [api_version: 1.5.1] [message: Starting Agent API server]

However portainer/agent:latest is broken (with the errors I've logged above)

@deviantony
Copy link
Member

deviantony commented Oct 28, 2019

@nemchik indeed we'll investigate that one.

EDIT: updated, should be fixed.

@nemchik
Copy link

nemchik commented Nov 5, 2019

Seems resolved for me. Thanks!

@deviantony deviantony removed this from the 1.5.1 milestone Nov 5, 2019
@deviantony deviantony changed the title Support deployment in Swarm cluster with macvlan network Unable to retrieve local agent IP address with agent 1.5.0 Nov 5, 2019
@deviantony deviantony removed the enhancement New feature or request label Nov 5, 2019
@deviantony deviantony added the bug Something isn't working label Nov 5, 2019
@deviantony deviantony modified the milestones: next, 1.5.1 Nov 5, 2019
@deviantony
Copy link
Member

Just a bit of re-organisation for this issue.

Sorry @UniverseXXX please re-open a new issue regarding the support of Macvlan if you're still interested in seeing this.

@JuezFenix
Copy link

Using version 2.0.0, 1.5.1 or latest same issue here.

`2021/01/12 14:31:32 [INFO] [main] [message: Agent running on Docker platform]

2021/01/12 14:31:32 [ERROR] [main,docker] [message: Unable to retrieve local agent IP address] [error: Error: No such container: da585a09ce2a]

2021/01/12 14:31:58 [WARN] [os,options] [message: the CAP_HOST_MANAGEMENT environment variable is deprecated and will likely be removed in a future version of Portainer agent]`

@Svedrin
Copy link

Svedrin commented Feb 25, 2021

I just found out that the Agent needs to be able to find a Docker container with an ID that matches its hostname. So if you nuke and recreate the container, be sure not to keep the hostname the same when Docker gives the container a new ID.

@realdeadbeef
Copy link

I have this same problem, I've got a feeling that it's to do with the fact that my server has a Wi-Fi connection and Ethernet connection both with different IP addresses, is there a way to get the agent to just bind to one of the IP addresses. eg: [docker deployment command] --bind 192.168.10.4:9001

@zeqk
Copy link

zeqk commented Aug 19, 2021

I had the same issue. I fix this running this command

 sudo docker swarm leave --force

(In my case, I don't need swarm)

@shubham-vunet
Copy link

I had the same issue. I fix this running this command

 sudo docker swarm leave --force

(In my case, I don't need swarm)

+1

@timdonovanuk
Copy link

@nemchik indeed we'll investigate that one.

EDIT: updated, should be fixed.

It isn't.

@mortee
Copy link

mortee commented Mar 18, 2022

I've been running Agent in swarm mode using the 2.7.0 image (not sure which Agent version that corresponds to) on Ubuntu 20 with no problems whatsoever, then suddenly it started spitting these messages in the log. Deleted the container and pulled 2.12.1, but the result is the same.

This coincided with the only swarm manager node being updated from Armbian 10 to 11, but I fail to see how that could cause an unchanged worker node to become unable to detect its own IP address.

@Olegt0rr
Copy link

Olegt0rr commented May 6, 2022

Please reopen.
The same issue with portainer/agent:2.11.1

@radeksh
Copy link

radeksh commented Nov 16, 2022

Same with portainer/agent:2.15.1

@hazdev
Copy link

hazdev commented Dec 31, 2022

Same thing happens with portainer/agent:2.16.2

However, I've found solution; adding the env var AGENT_CLUSTER_ADDR: localhost solved it for me, (single node swarm). Only found it after switching to the dev image and finding logs that it was missing

@zerak
Copy link

zerak commented Jan 12, 2023

That's save my time.
Microk8s install with agent-k8s-nodeport.

@amedveshchek
Copy link

amedveshchek commented Mar 9, 2024

To expand the @hazdev's answer:

docker run -d \
  -e AGENT_CLUSTER_ADDR=localhost \
  -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 \
  portainer/agent:2.19.4

So this -e AGENT_CLUSTER_ADDR=localhost did the trick.

@caretakerscurse
Copy link

To expand the @hazdev's answer:

docker run -d \
  -e AGENT_CLUSTER_ADDR=localhost \
  -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 \
  portainer/agent:2.19.4

So this -e AGENT_CLUSTER_ADDR=localhost did the trick.

THANK YOU!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.