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.

  • Error connecting to python server running in boot2docker (centos container | Windows 7.1 host)
  • PDAL: filters.outlier: Unexpected argument 'extract'
  • docker build running out of memory, but plenty of memory seems to be available
  • Continuous delivery for Docker deployment with image already built
  • Running Chromium inside Docker - Gtk: cannot open display: :0
  • SaltStack master/minion to administrate my database that is inside a container
  • Does anyone know how should I construct the request URL and body for this REST API?

  • How to check if a process is running inside docker container
  • webdriver container in circleci for testing
  • docker COPY without save point
  • How to use GC in Docker Registry without accessing container
  • Docker compose command user selection
  • Android Development Dockerfile: Why Does Android SDK Manager Hang?
  • 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.