How to use `docker-machine create` so that the docker engine listens on a custom port?

My service provider does not allow me to connect to docker on port 2376. Is there a flag for docker-machine to set up docker on host to listen on another port but 2376 so that commands like

docker-machine ls
OR
docker-machine env

  • Ports not accessible in Docker on Mac
  • How to ship python application through docker
  • Disable CSS and Javascript cache in nginx server created with Docker
  • after delete docker image, why can still find the deleted image by _catlog api?
  • Deis docker image deploy
  • How to expose my pod to the internet and get to it from the browser?
  • work? Now they fail because after creation of docker on the host the daemon starts on port 2376 which is not accessible. Sure, I could manually change that port after creation but then the mentioned commands are not aware to connect to the docker daemon on that host on another port but 2376.

  • Is it practical to deploy an asterisk server using Docker?
  • Docker: using Using --volumes-from to backup data files
  • docker deploy vs docker stack deploy
  • Why docker build image from docker file will create container when build exit incorrectly?
  • How can I install pdal in python in a dockerfile?
  • docker is not VM , why container need base image OS ? [closed]
  • One Solution collect form web for “How to use `docker-machine create` so that the docker engine listens on a custom port?”

    Is there a flag for docker-machine to set up docker on host to listen on another port but 2376

    yes, use the -H or --host option of the docker daemon command. To make your Docker daemon listen on port 443 (which should be open all most firewalls), start your docker daemon with:

    docker daemon -H tcp://0.0.0.0:443
    

    If your docker host operating system is Debian or Ubuntu, you can set this in the /etc/default/docker file by adding the line DOCKER_OPTS="-H tcp://0.0.0.0:443".

    If you are using RedHat or CentOS, add OPTIONS=-H tcp://0.0.0.0:443 to the /etc/sysconfig/docker file.


    Using docker-machine

    To install a Docker engine with a custom --host option, you would use docker machine with the --engine-opt option:

    docker-machine create --engine-opt host=tcp://0.0.0.0:443 ...
    

    Then when you use docker-machine env ... you will note that the DOCKER_HOST environment variable will still be set with the default port 2376, but now you can override it with 443 and it will work.

    Unfortunately this won’t allow docker-machine ls to work as the 2376 value for the docker engine port is hardcoded in docker-machine drivers. If you really want to get docker-machine ls to work for a different port, the easiest way would be to duplicate one of the docker-machine driver source file that you use and hardcode a different port ; then compile a new docker-machine binary with your new driver.


    Let’s say the IP address of the remote server is 11.22.33.44.

    # create the docker engine using the generic Machine driver
    docker-machine create --engine-opt host=tcp://0.0.0.0:443 --driver=generic --generic-ip-address=11.22.33.44 mytestengine
    
    # prepare the environments so that docker client can connect on port 443
    docker-machine env mytestengine
    export DOCKER_HOST=tcp://11.22.33.44:443
    
    # use docker client as usual
    docker version
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.