couldn’t run hadoop on docker swarm in vagrant

I have 4 vagrant machines running and source code for vagrant environment is here.

I’m successfully able to create a swarm cluster.

    $ docker node ls
    ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
    iq7i01ns7ku7zrtaemiucoawi *          Ready               Active              Leader              19.03.2
    g6mug58tld4aikobdv3ic9p9y         Ready               Active                                  19.03.2
    uc13xcl9ttauzkqdz03kbrewt         Ready               Active                                  19.03.2
    c8uhfvyhhlmuxp2p3ei3ymrj5         Ready               Active                                  19.03.2

Then I tried to deploy the hadoop on this swarm cluster docker stack deploy -c docker-compose-v3.yml hadoop

    $ docker service ls
    ID                  NAME                     MODE                REPLICAS            IMAGE                                                    PORTS
    vdup21ia02lr        hadoop_datanode          global              0/4                 bde2020/hadoop-datanode:2.0.0-hadoop3.1.2-java8          
    bo2ysglr2ajj        hadoop_historyserver     replicated          0/1                 bde2020/hadoop-historyserver:2.0.0-hadoop3.1.2-java8     
    o9z5mm2kja3c        hadoop_namenode          replicated          0/1                 bde2020/hadoop-namenode:2.0.0-hadoop3.1.2-java8          
    wx6kra4gzwxd        hadoop_nodemanager       global              0/4                 bde2020/hadoop-nodemanager:2.0.0-hadoop3.1.2-java8       
    k8roch02i7q0        hadoop_resourcemanager   replicated          0/1                 bde2020/hadoop-resourcemanager:2.0.0-hadoop3.1.2-java8

Also, I tried to get logs for namenode but it has no logs

    $ docker service logs hadoop_namenode

There was an error in datanode logs which is here.

The respective ip and hostname of docker nodes are here.
How can I fix this issue and make the hadoop cluster run vagrant swarm cluster?

Source: StackOverflow