Get docker API engine exec output

I try to get the output from a command Im running inside a container, but I only get it in RAW text so far. I need to be able to get the output with PHP, seems like I cant do that when it returns in RAW text.

Here is my Dockerfile:

  • Build docker in ASP.NET Core: “no such file or directory” error
  • I run the docker images which start tomcat8 server but it don't start
  • Docker mysql cant connect to container
  • Graphite installation in a docker container - volume query
  • How to speed up an Azure web application deployment with lots of files?
  • How can I create and use a variable inside docker?
  • FROM phusion/baseimage:0.9.19
    CMD ["/sbin/my_init"]
    WORKDIR /root
    RUN sed -i "s/^exit 101$/exit 0/" /usr/sbin/policy-rc.d
    RUN apt-get update
    RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y \
        nginx \
        php-fpm php-mysql php-gd php-curl php-cli php-mbstring php-dom unzip
    RUN service php7.0-fpm start
    EXPOSE 80
    RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

    And here is the curl requests Im running:

    ## Create container
    curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -d '{"Image":"test-container","Env":[""]}' -X POST http:/v1.27/containers/create?
    ## Start container
    curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -X POST http:/v1.27/containers/
    ## Create exec instance
    curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -d '{ "AttachStdin":false,"AttachStdout":true,"AttachStderr":true, "Tty":false, "Cmd":["/bin/bash", "-c", "date"] }' -X POST http:/v1.27/containers/
    ## Start exec instance
    curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -d '{ "Detach": false, "Tty": false }' -X POST http:/v1.27/exec/bcd34186a9a7360809cace3674fec03bd1c70c1c453be24ad058a03fa0b0e960/start
    // Sun Mar 26 23:23:53 UTC 2017

    Output from docker info:

    Containers: 8
    Running: 4
    Paused: 0
    Stopped: 4
    Images: 152
    Server Version: 17.03.0-ce
    Storage Driver: overlay2
    Backing Filesystem: extfs
    Supports d_type: true
    Native Overlay Diff: true
    Logging Driver: json-file
    Cgroup Driver: cgroupfs
    Volume: local
    Network: bridge host ipvlan macvlan null overlay
    Swarm: inactive
    Runtimes: runc
    Default Runtime: runc
    Init Binary: docker-init
    containerd version: 977c511eda0925a723debdc94d09459af49d082a
    runc version: a01dafd48bc1c7cc12bdb01206f9fea7dd6feb70
    init version: 949e6fa
    Security Options:
    Profile: default
    Kernel Version: 4.9.12-moby
    Operating System: Alpine Linux v3.5
    OSType: linux
    Architecture: x86_64
    CPUs: 2
    Total Memory: 1.952 GiB
    Name: moby
    Docker Root Dir: /var/lib/docker
    Debug Mode (client): false
    Debug Mode (server): true
    File Descriptors: 43
    Goroutines: 81
    System Time: 2017-03-26T23:25:45.809302866Z
    EventsListeners: 2
    No Proxy: *.local, 169.254/16
    Experimental: true
    Insecure Registries:
    Live Restore Enabled: false

    So, is there any proper way to get this output? Thanks for any help

  • Kubernetes installation conflicts with docker-ce-17.03.0
  • Docker fedora hbase JAVA_HOME issue
  • docker container won't start because an existing pid file
  • How to use the official docker elasticsearch container?
  • Docker build just freezes?
  • Docker Swarm Fault-tolerant Scheduling
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.