Docker Problems with AppDaemon

Currently have HA running on docker at 10.0.2.25:8123
Tried EXACTLY http://appdaemon.readthedocs.io/en/latest/DOCKER_TUTORIAL.html
but have problems. Tried my modification as this:

docker run --name appdaemon --rm -it -p 5050:5050 \
 -e HA_URL=“http://10.0.2.25:8123” \
 -e DASH_URL="http://10.0.2.25:5050" \
 -v /volume1/docker/appdaemon/config:/conf \
acockburn/appdaemon:latest

and that helped in that I can now see an appdaemon.yaml file created with proper HA_URL.

But I never get a connection. All I see is:
2018-07-10 13:26:31.847843 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds

Next, I opened up a terminal into this docker container and I was unable to ping the HA address or cURL to the HA page.

Do I need some kind of link? Note both docker containers are running on Synology NAS at 10.0.2.25.

i suspect you didnt configure appdaemon.
this part of the docs should be in bold i guess because lots of people miss it.

At this point forward, you can edit configurations on your conf folder and Appdaemon will load them see the AppDaemon Installation page for full instrctions on AppDaemon configuration. Have fun!

it contains a link to here: Getting started — AppDaemon 4.4.3 documentation
after you have had that part and configured AD you also need to configure the dashboard as told here:
Dashboard Install and Configuration — AppDaemon 4.4.3 documentation

I couldn’t see that you had done anything wrong, so I tried it myself, and get the same results - appdaemon doesn’t connect. I have the same configuration as my real (virtual env) environment, so there is nothing wrong with that.

I’m not sure what to suggest at the moment.

i thought you had AD up and running?
and you cant get a new install up?

I can’t get the docker image to work. Of course, I have AD running in a virtual environment, but there is no reason why I couldn’t have two ADs running.

I did configure appdaemon although most everything was correct from the run command. Here’s my pertinent parts from appdaemon.yaml. I have no api-key as #api_password: is commented during this local trial.

log:
  logfile: STDOUT
  errorfile: STDERR
appdaemon:
  threads: 10
  plugins:
    HASS:
      type: hass
      ha_url: “http://10.0.2.25:8123”
      ha_key:

I’ve not yet even considered the dashboard as I just want python scriptability with imports.

Did you read this in my post?

Next, I opened up a terminal into this docker container and I was unable to ping the HA address or cURL to the HA page.

I think that’s relevant.

i thought you used a docker image for AD. my mistake.

i am a bad help when it comes to docker. all i can point to is the docs and untill now that was enough in most cases :wink:

I changed my run to:

docker run --name appdaemon --net=host --privileged --rm -it -p 5050:5050
-e HA_URL=“http://10.0.2.25:8123” -e DASH_URL=“http://10.0.2.25:5050
-v /volume1/docker/appdaemon/config:/conf acockburn/appdaemon:latest

(Added the net=host and privileged flag.) I then opened a bash shell into this container:
curl http://10.0.2.25:8123/states

Gives me all of HA states but the log still logs:
2018-07-10 15:44:35.132126 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
Perhaps this never worked in separate containers although if cURL worked, it seems AD should provide some other log information. Is there a way for AD to tell why it’s not connecting?

This is interesting. When I ctrl-c out of the container, I got this in the log:

2018-07-10 15:46:50.211703 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
Above line repeated hundreds of times...
2018-07-10 15:47:35.234785 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-07-10 15:47:40.238213 INFO AppDaemon: HASS: Disconnecting from Home Assistant
2018-07-10 15:47:40.238713 INFO AppDeamon Exited

Noticed it said “Disconnecting” when it said retrying.

I am pretty sure I tried it once - but not for a few months.

I tried with DEBUG enabled and got this

$ docker run --rm -it --net=host -e EXTRA_CMD="-D DEBUG" -v /home/graham/appd_docker_test:/conf acockburn/appdaemon:latest
2018-07-10 15:59:04.911744 INFO AppDaemon Version 3.0.1 starting
2018-07-10 15:59:04.911956 INFO Configuration read from: /conf/appdaemon.yaml
2018-07-10 15:59:04.912043 DEBUG AppDaemon Section: None
2018-07-10 15:59:04.912127 DEBUG HADashboard Section: None
2018-07-10 15:59:04.914070 INFO AppDaemon: Starting Apps
2018-07-10 15:59:04.914890 DEBUG AppDaemon: Creating worker threads ...
2018-07-10 15:59:04.917495 DEBUG AppDaemon: Done
2018-07-10 15:59:04.917630 DEBUG AppDaemon: Entering run()
2018-07-10 15:59:04.917827 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2018-07-10 15:59:04.960168 INFO AppDaemon: HASS: HASS Plugin Initializing
2018-07-10 15:59:04.960527 INFO AppDaemon: HASS: HASS Plugin initialization complete
2018-07-10 15:59:04.960676 DEBUG AppDaemon: Starting utility loop
2018-07-10 15:59:04.960804 INFO Dashboards are disabled
2018-07-10 15:59:04.960894 INFO API is disabled
2018-07-10 15:59:04.960980 DEBUG Start Loop
2018-07-10 15:59:04.961547 DEBUG AppDaemon: Event type:ha_disconnected:
2018-07-10 15:59:04.961667 DEBUG AppDaemon: {}
2018-07-10 15:59:04.961765 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-07-10 15:59:04.961861 WARNING AppDaemon: HASS: ------------------------------------------------------------
2018-07-10 15:59:04.961944 WARNING AppDaemon: HASS: Unexpected error:
2018-07-10 15:59:04.962036 WARNING AppDaemon: HASS: ------------------------------------------------------------
2018-07-10 15:59:04.963538 WARNING AppDaemon: HASS: Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/appdaemon/plugins/hass/hassplugin.py", line 194, in get_updates
    "{}/api/websocket".format(url), sslopt=sslopt
  File "/usr/local/lib/python3.6/site-packages/websocket/_core.py", line 494, in create_connection
    websock.connect(url, **options)
  File "/usr/local/lib/python3.6/site-packages/websocket/_core.py", line 217, in connect
    options.pop('socket', None))
  File "/usr/local/lib/python3.6/site-packages/websocket/_http.py", line 57, in connect
    hostname, port, resource, is_secure = parse_url(url)
  File "/usr/local/lib/python3.6/site-packages/websocket/_url.py", line 49, in parse_url
    raise ValueError("hostname is invalid")
ValueError: hostname is invalid

so I added http: to my url and it worked. But I see you have that. The only difference I can see is that I don’t have quotes. Maybe try that ?

I had this issue when using the yaml configuration file, instead I passed the environmental values to it via docker compose / run and it worked strangely enough.

Did not verify it, but it seems to be that priority for the ha_url is given to the environment variable. So changing the config file is not enough - check your env vars. The url should be looking like next: “http://homeassistant:8123