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.

  • Prometheus - how to monitor other docker containers
  • How to dockerize
  • one docker daemon can support how many docker containers? [closed]
  • Command works on bash but not on cron
  • Adding a Local GIT Repository to a Gogs Docker Container
  • trapping signal from “docker stop” in bash
  • How?

  • Docker container only accessible by another
  • Docker-compose volumes doesn't copy any files
  • error executing curl command in dockerfile
  • How to create Ubuntu (running) base image to replicate on other environments.
  • Docker: Setting up a GUI in a Docker Container on a Raspberry Pi
  • Centos 6.6, python 2.7.2 object has no attribute 'StringIO
  • 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.