Installing Sensu in Docker Desktop on Windows 10

Hi,

I’ve followed the installation guide for docker (Install Sensu - Sensu Docs).
I executed the “configure and start” command:

docker run -v /var/lib/sensu:/var/lib/sensu
-d --name sensu-backend
-p 3000:3000 -p 8080:8080 -p 8081:8081
-e SENSU_BACKEND_CLUSTER_ADMIN_USERNAME=admin
-e SENSU_BACKEND_CLUSTER_ADMIN_PASSWORD=admin
sensu/sensu:latest
sensu-backend start --state-dir /var/lib/sensu/sensu-backend --log-level debug

Now, when I try to login to the web UI it says: Bad username or password.

curl http://127.0.0.1:8080/health gives me:
{“Alarms”:null,“ClusterHealth”:[{“MemberID”:17176087798454692206,“MemberIDHex”:“ee5db8d991d0296e”,“Name”:“default”,“Err”:“context deadline exceeded”,“Healthy”:false}],“Header”:{“cluster_id”:8120212534602823810,“member_id”:17176087798454692206,“raft_term”:10}}

I don’t know where to start looking for misconfigurations, any help greatly appreciated!

Best regards,
Jim

Hey,

So best thing to do when troubleshooting a docker container is to use docker logs <container-id>
in this case docker logs sensu-backend

You may be able to find an error message that gives you some insight.

But in this case, If I were a betting man… I’d bet you a doughnut the volume mount option is probably the problem. It could be that you are trying to volume mount a directory from the host system /var/lib/sensu to act as /var/lib/sensu in the container that you don’t have write permissions to or does not exist. You may need to adjust the volume mount argument in the example command to work for you Windows system. I can’t tell you what that argument should be, it just needs to be a directory you can write to so docker can mount it and use it to persist database information to.

You can start by just removing the -v /var/lib/sensu:/var/lib/sensu and see if that lets you get unstuck.
But ideally, you’ll want a persistent volume mount for /var/lib/sensu as this holds the backing store database for etcd, for your configuration. If you don’t have a persistent mount for this directory, you’ll lose state when you destroy the container (essentially losing all the work you did to configure your sensu resources…so having a persistent volume mount for that directory is very useful).

I hope this helps.

Hi,

Thanks a lot for your reply!

I removed everything from docker desktop (clean/purge data) in order to start over from scratch.

I tried both removing the -v /var/lib/sensu:/var/lib/sensu from the command and replacing /var/lib/sensu with c:/data/ (i.e. -v c:/data/:/var/lib/sensu). Unfortunately neither made any difference.

C:>docker run -v c:/data/:/var/lib/sensu -d --name sensu-backend -p 3000:3000 -p 8080:8080 -p 8081:8081 -e SENSU_BACKEND_CLUSTER_ADMIN_USERNAME=admin -e SENSU_BACKEND_CLUSTER_ADMIN_PASSWORD=admin sensu/sensu:latest sensu-backend start --state-dir /var/lib/sensu/sensu-backend --log-level debug
Unable to find image ‘sensu/sensu:latest’ locally
latest: Pulling from sensu/sensu
801bfaa63ef2: Pull complete 9916937d4d7c: Pull complete b0ddb18de775: Pull complete 63dd41191df7: Pull complete 99cf7622423f: Pull complete ca20dd78c5f6: Pull complete bd394dba1b3b: Pull complete 6bfaaaf12c49: Pull complete 41ebf0bdd4e5: Pull complete ef69dc59b9b7: Pull complete e9d339c32565: Pull complete 6260987306ad: Pull complete 885a479632ee: Pull complete 2d9c19fd7181: Pull complete 335c077337f0: Pull complete 8778efe10a24: Pull complete 4461b3f18ed7: Pull complete 3668a70bca0a: Pull complete ee987af2cdb9: Pull complete 0897e3d3ac24: Pull complete Digest: sha256:bb185f0b3024387d4701a549b232bd2178ddb88ba84fef04b1c3d0ba8fcbee51
Status: Downloaded newer image for sensu/sensu:latest
c1503c283ad0415a7b6a999a774f35918dd8f8af7751eb450207a1e233b4f964

C:>dir c:\data
Volume in drive C is OSDisk
Volume Serial Number is F453-7A41

Directory of c:\data

2021-02-10 12:10 .
2021-02-10 12:10 …
2021-02-10 12:10 sensu-backend
0 File(s) 0 bytes
3 Dir(s) 613 803 483 136 bytes free

C:>curl removed:8080/health
{“Alarms”:null,“ClusterHealth”:[{“MemberID”:10659232868307291187,“MemberIDHex”:“93ed33d1959fcc33”,“Name”:“default”,“Err”:“context deadline exceeded”,“Healthy”:false}],“Header”:{“cluster_id”:7818060805654690495,“member_id”:10659232868307291187,“raft_term”:2}}

C:>curl http://127.0.0.1:8080/version
{“etcd”:{“etcdserver”:“3.3.22”,“etcdcluster”:“3.3.0”},“sensu_backend”:“6.2.5”}

docker logs sensu-backend gives me the following output: gist:8b9d9709198a8cf9eccef758b449d833 · GitHub

Thanks again for helping out!

Hmm,
the logs definitely indicate there is a problem with the embedded etcd service coming up…which is unexpected.
I’ll dig up a windows 10 with docker tonight and try to reproduce.

Running docker my Fedora desktop just works…so I’m a little surprised this is falling over on Docker on Windows. It should just work.

How well do you know how to inspect a running docker container using the docker cmdline tool?
I think docker inspect will let you get the details … id be interested to see if docker sees tcp 2379 port is as exposed inside the service.

output of docker inspect sensu-backend has all the info.
Be careful about posting that… it has ENV secrets…so
you are looking for a section called ‘ExposedPorts’
should look like this.

                "2379/tcp": {},
                "2380/tcp": {},
                "3000/tcp": {},
                "8080/tcp": {},
                "8081/tcp": {}
            },

Thats all the tcp ports sensu-backend is using inside the container… embedded etcd (client and peer), web-ui, api, agent websocket

Hey,
So i just did a fresh instal of Docker for Windows 10 Pro,
The sensu instructions minus the volume mount argument definitely worked as I expected.
I was able to get to the dashboard just fine

Not sure what to tell you, it;s probably something in your docker setup but since I didn’t hit the problem myself its gonna be difficult for me to give you a good idea where to look. I think docker on windows is already sort of a special kinda magic, since there is a linux kernel somewhere deep in the guts of this.

I will say that when I installed the latest Docker for Windows it required me to install the WSL 2 components and do a couple of restarts of the OS before it was usable at all. But once I was able to run the Docker for Windows provided tutorial, the sensu backend install worked as I expected.

Hi again,

Thanks again for taking the time to help out! When looking at the output of docker inspect sensu-backend everything looks perfectly fine. I’m guessing something is wrong with my Win 10 + docker desktop + wsl - combo. I think I’ll resort to setting this up in a linux VM instead. I’ll keep in mind to post here if I’ll ever find out what was the cause of the issue.
Thanks!

Best regards,
Jim