portainer / portainer-compose

Compose setup for Portainer
http://portainer.io
681 stars 303 forks source link

templates not working #7

Closed kraeml closed 5 years ago

kraeml commented 7 years ago

Thanks for the docker-compose file.

I have problems with the templates engine.

I could start with docker-compose but the portainer template section is empty.

The portainer-app logs are:

2017/01/27 19:18:00 Starting Portainer on :9000 2017/01/27 19:18:57 http error: Get http://templates/templates.json: dial tcp 127.0.53.53:80: getsockopt: connection refused (code=500) 2017/01/27 19:29:43 http error: Get http://templates/templates.json: dial tcp 127.0.53.53:80: getsockopt: connection refused (code=500)

docker-compose ps

        Name                      Command               State               Ports
---------------------------------------------------------------------------------------------
portainer-app          /portainer --templates htt ...   Up      9000/tcp
portainer-proxy        nginx -g daemon off;             Up      443/tcp, 0.0.0.0:80->80/tcp
portainer-templates    nginx -g daemon off;             Up      443/tcp, 0.0.0.0:8080->80/tcp
portainer-watchtower   /watchtower --cleanup port ...   Up

From Host machine:

curl localhost:8080/templates.json
[
  {
    "title": "RPI-Registry",
    "description": "Docker image registry",
    "logo": "https://cloudinovasi.id/assets/img/logos/registry.png",
...

A ping on from proxy to templates are working and an curl from proxy are the same result as above from localhost.

docker exec -it portainer-proxy /bin/sh
/ # curl
/bin/sh: curl: not found
/ # apk add curl
WARNING: Ignoring APKINDEX.167438ca.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.a2e6dac0.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
  curl (missing):
    required by: world[curl]
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
v3.4.6-60-gc61f5bf [http://dl-cdn.alpinelinux.org/alpine/v3.4/main]
v3.4.6-33-g38ef2d2 [http://dl-cdn.alpinelinux.org/alpine/v3.4/community]
OK: 5976 distinct packages available
/ # apk add curl
(1/4) Installing ca-certificates (20161130-r0)
(2/4) Installing libssh2 (1.7.0-r0)
(3/4) Installing libcurl (7.52.1-r0)
(4/4) Installing curl (7.52.1-r0)
Executing busybox-1.24.2-r12.trigger
Executing ca-certificates-20161130-r0.trigger
OK: 55 MiB in 28 packages
/ # curl http://templates/templates.json
[
  {
    "title": "RPI-Registry",
    "description": "Docker image registry",
...
deviantony commented 7 years ago

Strange, have you changed the content of the docker-compose.yml file? The portainer-templates container should not publish port 80 on 8080.

kraeml commented 7 years ago

Yes for testing. I changed my previous post.

deviantony commented 7 years ago

Wow, this is super strange. What about rebuilding the stack with docker-compose down && docker-compose up ?

kraeml commented 7 years ago

Yes, a couple of times but no result.

Here my docker-compose file:

version: '2'

services:
  proxy:
    build: nginx/
    container_name: "portainer-proxy"
    ports:
      - "80:80"
    networks:
      - local

  templates:
    image: portainer/templates
    container_name: "portainer-templates"
    ports:
      - "8080:80"
    networks:
      - local
    volumes:
      - ./templates/templates.json:/usr/share/nginx/html/templates.json

  portainer:
    image: portainer/portainer
    container_name: "portainer-app"
    command: --templates http://templates/templates.json -d /data
    networks:
      - local
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /opt/portainer/data:/data

  watchtower:
    image: centurylink/watchtower
    container_name: "portainer-watchtower"
    command: --cleanup portainer-app
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

networks:
  local:
    driver: bridge
kraeml commented 7 years ago

Her my output:

docker-compose down && docker-compose up
Stopping portainer-app ... done
Stopping portainer-watchtower ... done
Stopping portainer-proxy ... done
Stopping portainer-templates ... done
Removing portainer-app ... done
Removing portainer-watchtower ... done
Removing portainer-proxy ... done
Removing portainer-templates ... done
Removing network portainercompose_default
Removing network portainercompose_local
Creating network "portainercompose_default" with the default driver

Creating network "portainercompose_local" with driver "bridge"
Creating portainer-templates
Creating portainer-proxy
Creating portainer-app
Creating portainer-watchtower
Attaching to portainer-watchtower, portainer-app, portainer-templates, portainer-proxy
portainer-watchtower | time="2017-01-27T19:51:23Z" level=info msg="Checking containers for updated images"
portainer-app | 2017/01/27 19:51:23 Starting Portainer on :9000
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:42 +0000] "GET /portainer/ HTTP/1.1" 200 2349 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:42 +0000] "GET /portainer/css/app.502947a2.css HTTP/1.1" 304 0 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/
20100101 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:42 +0000] "GET /portainer/js/app.3768b445.js HTTP/1.1" 304 0 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20
100101 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:42 +0000] "GET /portainer/images/logo_alt.png HTTP/1.1" 304 0 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/2
0100101 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:43 +0000] "GET /portainer/api/settings HTTP/1.1" 200 32 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/2010010
1 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:43 +0000] "GET /portainer/api/users/admin/check HTTP/1.1" 200 21 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Geck
o/20100101 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:46 +0000] "POST /portainer/api/auth HTTP/1.1" 200 142 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101
Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:46 +0000] "GET /portainer/api/endpoints/0 HTTP/1.1" 200 72 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/2010
0101 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:46 +0000] "GET /portainer/api/docker/version HTTP/1.1" 200 221 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/
20100101 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:46 +0000] "GET /portainer/api/docker/info HTTP/1.1" 200 2308 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20
100101 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:46 +0000] "GET /portainer/images/logo.png HTTP/1.1" 304 0 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100
101 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:47 +0000] "GET /portainer/api/endpoints HTTP/1.1" 200 74 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/201001
01 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:47 +0000] "GET /portainer/api/docker/containers/json?all=1 HTTP/1.1" 200 5450 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64;
rv:50.0) Gecko/20100101 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:47 +0000] "GET /portainer/api/docker/networks HTTP/1.1" 200 3080 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Geck
o/20100101 Firefox/50.0" "-"
portainer-app | 2017/01/27 19:51:50 http error: Get http://templates/templates.json: dial tcp 127.0.53.53:80: getsockopt: connection refused (code=500)
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:50 +0000] "GET /portainer/api/templates HTTP/1.1" 500 103 "http://localhost/portainer/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100
101 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:50 +0000] "GET /portainer/images/ie-spacer.gif HTTP/1.1" 304 0 "http://localhost/portainer/css/app.502947a2.css" "Mozilla/5.0 (X11; Ubuntu; Linux x86
_64; rv:50.0) Gecko/20100101 Firefox/50.0" "-"
portainer-proxy | 172.19.0.1 - - [27/Jan/2017:19:51:50 +0000] "GET /portainer/images/gritter.png HTTP/1.1" 304 0 "http://localhost/portainer/css/app.502947a2.css" "Mozilla/5.0 (X11; Ubuntu; Linux x86_6
4; rv:50.0) Gecko/20100101 Firefox/50.0" "-"
deviantony commented 7 years ago

This is really weird. I just tried with the docker-compose.yml file that you provided above and it works well on my computer.

Sacro commented 7 years ago

By the response of 127.0.53.53 it looks like you're trying to connect using a hostname that doesn't belong to you and ICANN is warning you of it.

Either switch to a hostname (and relevant DNS) that you control, or use the straight IP (or add it to your hosts file)

https://www.icann.org/news/announcement-2-2014-08-01-en

kraeml commented 7 years ago

@deviantony The dockercompose file runs in a virtualbox. I think there is no error in dockercompse file.

@Sacro Thanks. So I found a workaround. I changed http://templates/templates.json into http://172.19.0.2/templates.json. And now it works. But I wondering, why the docker dns could not resolve the hostname templates only on the portainer-app machine?!

I tested with links and depends_on. Doesn't not work.

Sacro commented 7 years ago

It can resolve it, that's why it's attempting to connect to 127.0.53.53.

I'm guessing you're using a domain name ending in .dev or some other domain that you yourself don't own/manage.

kraeml commented 7 years ago

I didn't set any domain on my host machine and the docker-compose also didn't set any domain. So I wondering why I get a 127.0.53.53 for the hostname http://templates.

The container portainer-proxy, in network local, could resolve the hostname templates :-(

I dont't know how to setup the dns in a docker network.

Here the output:

docker network inspect portainercompose_local portainercompose_default 
[
    {
        "Name": "portainercompose_local",
        "Id": "642b180dea25299086d79ba6477ff7f995dabe6a48f92bf62618d80381f26aae",
        "Created": "2017-02-11T17:48:39.126649039+01:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {
            "42d74a6727b66c2d9bf0d55a381a800217e29a2aa177fa67dadd7e268326e548": {
                "Name": "portainer-templates",
                "EndpointID": "437f53f04da592d6373d82a271549ff29585e44f131a79a9a7103164edf92280",
                "MacAddress": "02:42:ac:13:00:02",
                "IPv4Address": "172.19.0.2/16",
                "IPv6Address": ""
            },
            "9c3b10b45358175d8b4572bcfe96362ca70b55a3ab2f40268dee9512eee50603": {
                "Name": "portainer-app",
                "EndpointID": "a66cf05ed2584f2f99fa9290844fe176dccd9722d8fd084c0c98ab0efa21706e",
                "MacAddress": "02:42:ac:13:00:04",
                "IPv4Address": "172.19.0.4/16",
                "IPv6Address": ""
            },
            "e9870787572a49430e39a0630e2ac16762ee0a23ea9a851a2799d4d9b8c67905": {
                "Name": "portainer-proxy",
                "EndpointID": "247163a3e23e75eb981fadc96f1efe77eece25115f73af03c004814996626c9e",
                "MacAddress": "02:42:ac:13:00:03",
                "IPv4Address": "172.19.0.3/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    },
    {
        "Name": "portainercompose_default",
        "Id": "5d6bd63038428f75d645bee99e2e3ab7f2c1d594983ec62a278d64c26bf59c0b",
        "Created": "2017-02-11T17:48:38.966106816+01:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {
            "730020d6756822735fff87d464177701d1550af1750d9431eed3c0d41d42571a": {
                "Name": "portainer-watchtower",
                "EndpointID": "dc41a960089f78879b5371d4bbda1c15f00bb57b23280e9e6b951b28a5097f2a",
                "MacAddress": "02:42:ac:12:00:02",
                "IPv4Address": "172.18.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]
ivandir commented 7 years ago

Hey @deviantony ,

I think you might need to merge together the portainer-compose and templates repos. I spend a couple of hours figuring this out and I don't know exactly why docker-compose is so buggy where it reuses volumes previously bound even after local files changed. If you find out why please let me know.

Here is my solution: git clone https://github.com/portainer/templates to the parent directory (same as ./data and ./nginx)

Update docker-compose.yml to rebuild the image every time so you get the updated templates.json. Here is the revised docker-compose.yml

  templates:
    build: templates/
    image: portainer/templates:dev
    container_name: "portainer-templates"
    networks:
      - local
deviantony commented 7 years ago

@ivandir what docker compose version are you using?

ivandir commented 7 years ago

docker-compose version 1.11.1, build 7c5d5e4 OS X Version 10.11.6 (15G1217)

deviantony commented 5 years ago

Should be fixed via https://github.com/portainer/portainer-compose/pull/20

Sacro commented 5 years ago

Fixed until the portainer tld becomes available at least.