01-31-2019 04:18 AM
Hi folks
I wonder if someone could assist me please. I am trying to get a docker based MQTT (mosquitto) server running on my IR828. This is a requirement for some IoT work we are doing.
I am using the super lightweight image from Docker Hub (https://hub.docker.com/_/eclipse-mosquitto) and I can build and run the image no issues on the dev machine. I can then package, install and activate the app on the 829. However, as soon as I start it, it stops. I am using NAT network settings, however, if I choose BRIDGE, then the container starts and continues to run (the log file does however say it is waiting for an IP address, so it can't be used). I tested the router setup with the simple nodejs web server docker example (https://developer.cisco.com/docs/iox/#!tutorial-build-sample-docker-type-nodejs-based-http-server-using-alpine-base-image/overview) and this works fine (using NAT config).
I'm not all that experienced with the creation files, so I think there may be an issue between the Dockerfile and my package.yaml file (below). The package.yaml is a modified version of the one from the nodejs webserver example.
I'm wondering if the app start process is not working, and maybe there is a clash between the Dockerfile config and the package.yaml file config.
There is also nothing specific in the either the watchdog or container log.
Any help much appreciated.
Thanks
Andre
Dockerfile:
FROM alpine:3.8 LABEL maintainer="Roger Light <roger@atchoo.org>" \ description="Eclipse Mosquitto MQTT Broker" ENV VERSION=1.5.5 \ DOWNLOAD_SHA256=fcdb47e340864c545146681af7253399cc292e41775afd76400fda5b0d23d668 \ GPG_KEYS=A0D6EEA1DCAE49A635A3B2F0779B22DFB3E717B7 \ LWS_VERSION=2.4.2 RUN set -x && \ apk --no-cache add --virtual build-deps \ build-base \ cmake \ gnupg \ libressl-dev \ util-linux-dev && \ wget https://github.com/warmcat/libwebsockets/archive/v${LWS_VERSION}.tar.gz -O /tmp/lws.tar.gz && \ mkdir -p /build/lws && \ tar --strip=1 -xf /tmp/lws.tar.gz -C /build/lws && \ rm /tmp/lws.tar.gz && \ cd /build/lws && \ cmake . \ -DCMAKE_BUILD_TYPE=MinSizeRel \ -DCMAKE_INSTALL_PREFIX=/usr \ -DLWS_IPV6=ON \ -DLWS_WITHOUT_BUILTIN_GETIFADDRS=ON \ -DLWS_WITHOUT_CLIENT=ON \ -DLWS_WITHOUT_EXTENSIONS=ON \ -DLWS_WITHOUT_TESTAPPS=ON \ -DLWS_WITH_SHARED=OFF \ -DLWS_WITH_ZIP_FOPS=OFF \ -DLWS_WITH_ZLIB=OFF && \ make -j "$(nproc)" && \ rm -rf /root/.cmake && \ wget https://mosquitto.org/files/source/mosquitto-${VERSION}.tar.gz -O /tmp/mosq.tar.gz && \ echo "$DOWNLOAD_SHA256 /tmp/mosq.tar.gz" | sha256sum -c - && \ wget https://mosquitto.org/files/source/mosquitto-${VERSION}.tar.gz.asc -O /tmp/mosq.tar.gz.asc && \ export GNUPGHOME="$(mktemp -d)" && \ found=''; \ for server in \ ha.pool.sks-keyservers.net \ hkp://keyserver.ubuntu.com:80 \ hkp://p80.pool.sks-keyservers.net:80 \ pgp.mit.edu \ ; do \ echo "Fetching GPG key $GPG_KEYS from $server"; \ gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \ done; \ test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \ -DLWS_WITH_ZLIB=OFF && \ make -j "$(nproc)" && \ rm -rf /root/.cmake && \ wget https://mosquitto.org/files/source/mosquitto-${VERSION}.tar.gz -O /tmp/mosq.tar.gz && \ echo "$DOWNLOAD_SHA256 /tmp/mosq.tar.gz" | sha256sum -c - && \ wget https://mosquitto.org/files/source/mosquitto-${VERSION}.tar.gz.asc -O /tmp/mosq.tar.gz.asc && \ export GNUPGHOME="$(mktemp -d)" && \ found=''; \ for server in \ ha.pool.sks-keyservers.net \ hkp://keyserver.ubuntu.com:80 \ hkp://p80.pool.sks-keyservers.net:80 \ pgp.mit.edu \ ; do \ echo "Fetching GPG key $GPG_KEYS from $server"; \ gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \ done; \ test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \ gpg --batch --verify /tmp/mosq.tar.gz.asc /tmp/mosq.tar.gz && \ gpgconf --kill all && \ rm -rf "$GNUPGHOME" /tmp/mosq.tar.gz.asc && \ mkdir -p /build/mosq && \ tar --strip=1 -xf /tmp/mosq.tar.gz -C /build/mosq && \ rm /tmp/mosq.tar.gz && \ make -C /build/mosq -j "$(nproc)" \ CFLAGS="-Wall -O2 -I/build/lws/include -flto" \ LDFLAGS="-L/build/lws/lib -flto" \ WITH_ADNS=no \ WITH_DOCS=no \ WITH_MEMORY_TRACKING=no \ WITH_SHARED_LIBRARIES=no \ WITH_SRV=no \ WITH_STRIP=yes \ WITH_TLS_PSK=no \ WITH_WEBSOCKETS=yes \ prefix=/usr \ binary && \ addgroup -S -g 1883 mosquitto 2>/dev/null && \ adduser -S -u 1883 -D -H -h /var/empty -s /sbin/nologin -G mosquitto -g mosquitto mosquitto 2>/dev/null && \ mkdir -p /mosquitto/config /mosquitto/data /mosquitto/log && \ install -d /usr/sbin/ && \ install -s -m755 /build/mosq/src/mosquitto /usr/sbin/mosquitto && \ install -s -m755 /build/mosq/src/mosquitto_passwd /usr/bin/mosquitto_passwd && \ install -m644 /build/mosq/mosquitto.conf /mosquitto/config/mosquitto.conf && \ chown -R mosquitto:mosquitto /mosquitto && \ apk --no-cache add \ libuuid && \ apk del build-deps && \ rm -rf /build VOLUME ["/mosquitto/data", "/mosquitto/log"] # Set up the entry point script and default command COPY docker-entrypoint.sh / RUN chmod 777 /docker-entrypoint.sh ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["/usr/sbin/mosquitto", "-c", "/mosquitto/config/mosquitto.conf"]
Package.yaml:
descriptor-schema-version: "2.2" info: name: mqtt_docker description: "Simple Docker based MQTT server" version: "1.0" author-link: "" author-name: "" app: # Indicate app type (vm, paas, lxc etc.,) cpuarch: "x86_64" type: docker resources: profile: c1.small network: - interface-name: eth0 ports: tcp: [1883] # Specify runtime and startup startup: rootfs: rootfs.tar target: ["/usr/sbin/mosquitto", "-c", "/mosquitto/config/mosquitto.conf"]
01-31-2019 04:26 AM
01-31-2019 05:18 AM
Thanks Steve, I'll give it a go when I'm back in the lab.
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: