Can not curl docker swarm from remote host

I’m trying to test how to interact with docker swarm using docker API. I have an ec2 instance in AWS running docker. I need to connect to it from my local machine using curl then initialize the swarm and get the join tokens after to use it to connect 2 other ec2 instances to the swarm. I need to do all of that using curl only.

I created the swarm manually by ssh’ing to the instance and running:

  • Scaling microservices using Docker
  • supervisor curl command failing with exit 56 error
  • Docker port isn't accessible from host
  • Install docker 1.2 on Amazon Linux AMI release 2014.03
  • Running multiple docker instances in EC2
  • Docker: change folder where to store docker volumes
  • docker swarm init --advertise-addr 10.0.0.2
    

    and then I tried running this curl command:

    curl 10.0.0.2:2377/swarm
    curl 10.0.0.2:2377/info
    

    and I get an empty line. If I try changing the port to 2376 I get connection refused error.

    What am I missing?

    running netstat -tuplen, found the following result:

    enter image description here

  • Kubernetes Pod Creation Speed
  • Docker: how to send a signal from one running container to another one?
  • How to link docker images to their composing layers on the disk?
  • localhost within docker user defined network?
  • Simple docker-compose with two services: nginx and php
  • Are there disadvantages when running a docker base image that differs from my distribution?
  • One Solution collect form web for “Can not curl docker swarm from remote host”

    To pull the answer out of the comments: By default accessing the remote API has to be done with https authentication. You can turn that off but this isn’t recommended for production apps. There may be a way to write an authorization plugin that will allow other forms of authentication access.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.