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.

  • How to create a docker container out of existing project on Ubuntu
  • Go+MySql: how easy is to migrate to GKE (Google Cloud Container Engine)?
  • Setting up X11 display: One application works while other one don't
  • container running but cannot be visited in browser
  • Docker connect database from a container (laravel) to other container (wordpress)
  • “Peer's certificate issuer has been marked as not trusted by the user” in Openshift3
  • So, how can I create a container with the API and then start it with the cli and still pass these parameters ?


  • Setting the hostname for a container running in Kubernetes
  • fdisk doesn't find loop device in docker
  • Docker application deployment DEV vs TEST
  • Docker + MYSQL: Can't access mysql outside the container
  • Accessing a node.js Hapi server running inside a docker container
  • How to communicate (network) with Docker at DigitalOcean?
  • 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.