Set `–net-alias` using Docker API?

I have the following flow using following docker APIs:

  • build image
  • create container
  • connect container to network (using existing network id)
  • start container

I would like to somehow set the alternative network name for the container, i.e. so called network alias that in CLI can be set using the --net-alias.

  • HttpClient request on networked docker container
  • Should Node.js and MongoDB be in different pods?
  • How to run Docker on Ubuntu 15.04?
  • REPOSITORY <none> TAG <none>
  • How do I forward a docker-machine port to my host port on OSX?
  • Docker Build Error
  • How?

  • Running Asterisk and it's mysql database in different docker containers
  • Docker registry mirror not saving images with minikube
  • Syntaxnet spec file and Docker?
  • Gulp build into Docker container when NODE_ENV=production
  • can not ping as normal user in Docker centos image
  • Docker build MySQL dockerfile occur none:none
  • One Solution collect form web for “Set `–net-alias` using Docker API?”

    It was in the docs, although not so explicitly: by providing the body with EndpointConfig you may set the alias:

    {
        "Container": containerId,
        "EndpointConfig": {
            "Aliases": ["alias1"]
    
    }
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.