2

I'm a newbie in Docker/Docker Swarm and I want to create a custom mosquitto service on Swarm. I created a custom mosquitto image lcsf/mosquitto3 from ubuntu:latest, then I added some tools (ping, ipconfig). I can run a single container with docker run and /bin/bash, but I can't create a Swarm service with that image. The service isn't created successfully. There are some outputs below.

Dockerfile:

FROM ubuntu:latest RUN apt-get -y update RUN apt-get install -y mosquitto mosquitto-clients EXPOSE 80 443 1883 8083 8883

Docker service create output:

overall progress: 0 out of 1 tasks 1/1: preparing [========> ] verify: Detected task failure

This output is shown in a loop, then I stop it using ctrl+c, the service is created, but doesn't run, with 0/1 replicas.

Docker service ps mqtt (my custom name) output, there are 3 nodes.

ID NAME IMAGE NODE
DESIRED STATE CURRENT STATE ERROR PORTS llqr0gysz4bj mqtt.1 lcsf/mosquitto3:latest Docker02 Ready Ready 2 seconds ago kcwfqovyn2mp \_ mqtt.1 lcsf/mosquitto3:latest Docker03 Shutdown Complete 2 seconds ago ruisy599nbt4 \_ mqtt.1 lcsf/mosquitto3:latest Docker03 Shutdown Complete 7 seconds ago xg1lib5x8vt9 \_ mqtt.1 lcsf/mosquitto3:latest Docker02 Shutdown Complete 13 seconds ago fgm9wu25t0lj \_ mqtt.1 lcsf/mosquitto3:latest Docker03 Shutdown Complete 18 seconds ago

That's it, I hope someone can help me. Thanks in advance and I'm sorry 'bout my English and Stack Overflow skills.

UPDATE #1

Output from journalctl -f -n10 command after tying to create the service:

Sep 25 09:01:03 Docker01 dockerd[1230]: time="2017-09-25T09:01:03.692391553-04:00" level=info msg="Node join event for Docker02-a9b6d39043d3/192.168.222.51" Sep 25 09:01:15 Docker01 systemd-udevd[31966]: Could not generate persistent MAC address for veth8e5ebcb: No such file or directory Sep 25 09:01:15 Docker01 systemd-udevd[31967]: Could not generate persistent MAC address for vethaf2978b: No such file or directory Sep 25 09:01:15 Docker01 kernel: docker0: port 1(vethaf2978b) entered blocking state Sep 25 09:01:15 Docker01 kernel: docker0: port 1(vethaf2978b) entered disabled state Sep 25 09:01:15 Docker01 kernel: device vethaf2978b entered promiscuous mode Sep 25 09:01:15 Docker01 kernel: IPv6: ADDRCONF(NETDEV_UP): vethaf2978b: link is not ready Sep 25 09:01:15 Docker01 kernel: eth0: renamed from veth8e5ebcb Sep 25 09:01:15 Docker01 kernel: IPv6: ADDRCONF(NETDEV_CHANGE): vethaf2978b: link becomes ready Sep 25 09:01:15 Docker01 kernel: docker0: port 1(vethaf2978b) entered blocking state Sep 25 09:01:15 Docker01 kernel: docker0: port 1(vethaf2978b) entered forwarding state Sep 25 09:01:15 Docker01 kernel: docker0: port 1(vethaf2978b) entered disabled state Sep 25 09:01:15 Docker01 kernel: veth8e5ebcb: renamed from eth0 Sep 25 09:01:15 Docker01 kernel: docker0: port 1(vethaf2978b) entered disabled state Sep 25 09:01:15 Docker01 kernel: device vethaf2978b left promiscuous mode Sep 25 09:01:15 Docker01 kernel: docker0: port 1(vethaf2978b) entered disabled state Sep 25 09:01:33 Docker01 dockerd[1230]: time="2017-09-25T09:01:33.693508463-04:00" level=info msg="Node join event for Docker03-f71a448c54c7/192.168.222.52" Sep 25 09:01:46 Docker01 dockerd[1230]: time="2017-09-25T09:01:46.541311475-04:00" level=info msg="Node join event for Docker02-a9b6d39043d3/192.168.222.51" Sep 25 09:01:57 Docker01 dockerd[1230]: sync duration of 3.001217113s, expected less than 1s Sep 25 09:02:03 Docker01 dockerd[1230]: time="2017-09-25T09:02:03.694876667-04:00" level=info msg="Node join event for Docker03-f71a448c54c7/192.168.222.52" Sep 25 09:02:33 Docker01 dockerd[1230]: time="2017-09-25T09:02:33.695993259-04:00" level=info msg="Node join event for Docker03-f71a448c54c7/192.168.222.52"

UPDATE #2

This is the output from docker service ps --no-trunc mqtt command

ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS bour693j8jbbrt799fz0nkpwr mqtt.1 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker03 Ready Ready 4 seconds ago wro6254cs94gkijs8s4v9cvim \_ mqtt.1 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker03 Shutdown Complete 4 seconds ago 7vgx2mehaxki2p680fesn5jww \_ mqtt.1 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker03 Shutdown Complete 10 seconds ago 52hv6da6mj72s64po3hze4ham \_ mqtt.1 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker03 Shutdown Complete 15 seconds ago e3s383vtg0idw8ryxwh2y3gmu \_ mqtt.1 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker03 Shutdown Complete 21 seconds ago 90i30f3riwka8xs187xi7uxt2 mqtt.2 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker02 Ready Ready less than a second ago p2lzd04tinjdjkwkr26umlh9a \_ mqtt.2 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker02 Shutdown Complete less than a second ago q8awoj8uu7gad6hvonhl4t9f1 \_ mqtt.2 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker02 Shutdown Complete 6 seconds ago 1fuqt0et7vw1vntd8p62jiiut \_ mqtt.2 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker02 Shutdown Complete 11 seconds ago k3vlusok792zw0v3yddxqlmg3 \_ mqtt.2 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker02 Shutdown Complete 17 seconds ago i4tywshqv4pxsyz5tz0z0evkz mqtt.3 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker01 Ready Ready less than a second ago 44ee4iqqpkeome4lokx9ykmbo \_ mqtt.3 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker01 Shutdown Complete less than a second ago kdx273e9fkpqkafztif1dz35q \_ mqtt.3 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker01 Shutdown Complete 6 seconds ago l2oewfnwbkia94r6rifbcfi4h \_ mqtt.3 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker01 Shutdown Complete 11 seconds ago dyekgkd0swsualssw4dtvk681 \_ mqtt.3 lcsf/mosquitto3:latest@sha256:beca44e5f916d08730dd19d9d10dd2dcbd3502866f69316806a63bc094a179a9 Docker01 Shutdown Complete 17 seconds ago

7
  • Run journalctl -f -n10 in one terminal and in other terminal try to create the service. You will find the issue in the journalctl terminal. Please report that issue in question Commented Sep 25, 2017 at 5:24
  • I couldn't reply the output here, it's too long, then I added it in the question. Commented Sep 25, 2017 at 13:08
  • Restart all your nodes and try again Commented Sep 25, 2017 at 13:26
  • docker service ps --no-trunc {serviceName} is a potential way to see the reason for problems as stated in my so thread here amongst others. Commented Sep 25, 2017 at 13:38
  • @TarunLalwani I tried it and also restarted the swarm, but still does the same thing. @herm I added the docker service ps --no-trunc {serviceName} output in the question. Commented Sep 25, 2017 at 15:48

1 Answer 1

3

Your issue is your dockerfile. You are running bash command on a swarm service. You need to run a command which doesn't exist

FROM ubuntu:latest
RUN apt-get -y update
RUN apt-get install -y mosquitto mosquitto-clients
EXPOSE 80 443 1883 8083 8883
CMD ["tail", "-f", "/dev/null"]

This is a infinite tail command, which will make sure your container doesn't exit. Run a command in image that is not looking for user input when deploying to swarm.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Now all the replicas are running! Thanks everyone who helped me.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.