Create a new image using REST API by placing the content in the request body

I am following the “Create an image” REST API for docker mentioned at .

I want to create an image by placing the content in the request body. The explanation on the link does not specify exactly how the request and request body should look like in this scenario.

  • DNS resolution with the container
  • How to SSH into running container using docker
  • Authorization Not working with identityserver4 when using docker
  • How to run protractor end to end tests in docker container?
  • cant start docker after installation on linux
  • Building a generic Camel/Docker image and apply different Camel routes when container starts
  • Does anyone know how should I construct the request URL and body for this REST API?

  • How to build archlinux pkgbuild inside docker with gitlab-ci
  • Can't find equivalent of 'docker node ps' in Docker Python SDK
  • etcd - Is it possible to setup pubsub using etcd?
  • Nodejs private module and Docker containers
  • How to use volumes-from in marathon
  • Docker - How to open a debug port for AEM
  • One Solution collect form web for “Create a new image using REST API by placing the content in the request body”

    By tracing the behavior of the docker import command, it is apparent that the /images/create endpoint expects data in the form of a tar archive containing the files to populate the image. I after creating a simple archive containing a single file:

    tar -c -f image.tar README

    I was able to upload the image like this:

    curl http://localhost:5555/images/create'?fromSrc=-&repo=larstest&tag=latest' \
      -T image.tar -X POST

    The response from docker was:

    HTTP/1.1 200 OK
    Content-Type: application/json
    Date: Wed, 26 Aug 2015 15:10:10 GMT
    Transfer-Encoding: chunked

    You can trace the behavior of the docker client by setting up a logging proxy between the client and the server. I did this:

    socat -v tcp-listen:5555,fork,reuseaddr unix-connect:/var/run/docker.sock

    And then ran docker like this:

    DOCKER_HOST=tcp://localhost:5555 docker import - larstest < image.tar
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.