Need Explanation for the docker documentation on the swarm

I finished this documentation:

https://docs.docker.com/swarm/install-w-machine/

  • Add new Tomcat containers behind Apache with Docker
  • How to check ruby version inside docker container
  • Building docker image from Dockerfile: cannot start container
  • Docker run without setting WORKDIR doesn't work
  • Connect to SQL Server database from a docker container
  • Using values of command line arguments in a file other than entrypoint.sh
  • It works fine.

    Now I tried to setup this EC2 instances by following this documentation:

    https://docs.docker.com/swarm/install-manual/

    I am in Step 4. Set up a discovery backend

    I cannot understand the steps what I need to do further.

    I created 5 nodes in EC2: manager0, manager1, consul0, node0, node1. Now I need to know how to setup service discovery with swarm.

    In that document they ask us to connect manager0 and consul0 then ifconfig, then they given as etc0 instance. I don’t know where this is coming from.

    Ultimately I need to know where (in which node?) to run this command:

    $ docker run -d -p 8500:8500 --name=consul progrium/consul -server -bootstrap

    Any suggestion for me How to clear this step?

  • docker: Fatal Error Unable to create lock file: Bad file descriptor (9)
  • Sort by memory usage in docker stats
  • Security of Docker as it runs as root user
  • Using Docker I get the error: “SQLSTATE[HY000] [2002] No such file or directory”
  • How to define OpenJDK 8 in CentOS based Dockerfile?
  • Using docker and docker-compose in order to run npm install and bower install
  • One Solution collect form web for “Need Explanation for the docker documentation on the swarm”

    Consul will run on the consul0 server you created. So basically you first need to be able to run docker on worker0 and worker1 remotely, this is step 3. A better way of doing this is editing the daemon directly with the command:

    sudo echo 'DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"' > /etc/default/docker`
    

    Then restart docker. Afterwards you will find that you can run docker remotely from master0, master1 or any other instance behind your firewall with docker commands that start with:

    docker -H $WORKER0_IPADDRESS:2375 
    

    For example if your workers ip address was 1.2.3.4 this would run the docker ps command remotely:

    docker -H 1.2.3.4:2375 ps
    

    This is what swarm runs on. Then start up your consul server with the command you want to run, you got that one right and thats it you wont do anything else with the consul0 server except use its IP address when you run your swarm commands.

    So if $CONSUL0 represented the IP address of your consul server this is how you would set up the rest of swarm. If you ran each of them on the local machine of each node:

    On consul0:

    docker run -d -p 8500:8500 --restart=unless-stopped --name=consul progrium/consul -server -bootstrap
    

    On master0 and master1:

    docker run --name=master -d -p 4000:4000 swarm manage -H :4000 --replication --advertise $(hostname -i):4000 consul://$CONSUL0:8500
    

    On worker0 and worker1:

    docker run -d --name=worker swarm join --advertise=$(hostname -i):2375 consul://$CONSUL0:8500/
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.