docker – creating and starting container, differences between API and CLI

I want to create a (named) container through the API without starting it (otherwise I would have to manually stop it immediately, not very clean), and use systemd to manage it as a service, but I’m a bit confused between the CLI and the API involved…

In the API, some parameters for the container are given at the “start” phase and not at the creation, like volume-from, ports bindings, network mode, etc. while in the CLI it can only be given with the run command and not with the start.

  • Clojure: Connecting to a TLS enable docker daemon using aleph
  • Why does MySQL Docker container complain that MYSQL_ROOT_PASSWORD env must be defined when using Docker 17.03 secrets?
  • Configuring Hipache with etcd
  • How Do I Proxy Internal Nexus Docker Repositories?
  • Apache/php return full php error track description
  • python fabric run awk command return a KeyError: 'print $1'
  • So, how can I create a container with the API and then start it with the cli and still pass these parameters ?


  • Unable to follow sandbox link in Apache Mesos
  • Docker install nginx
  • Terminate docker compose when test container finishes
  • Can't create docker swarm service
  • Launch external program with multiple commands via Powershell
  • How to enable authentication on MongoDB through Docker?
  • One Solution collect form web for “docker – creating and starting container, differences between API and CLI”

    When creating the container, you’ll define which image you want to use and the command you want it to execute:

    POST /containers/create HTTP/1.1
    Content-Type: application/json
         "Cmd": "ls"

    Then in starting the container, you CAN override some of the container’s configuration (such as the Cmd), but otherwise, you will simply tell it to run with your volume or port bindings:

    POST /containers/(id)/start HTTP/1.1
    Content-Type: application/json
         "PortBindings":{ "22/tcp": [{ "HostPort": "11022" }] }

    The CLI, specifically, docker run creates, then starts the container in a single step.

    Simplified JSON blocks taken from the API documentation at

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