Docker build ubuntu:xenial issue

I try to build a docker image with docker-py in Jenkins.

The scripts looks like this:

# Let's build the toolchain-base-image
from io import BytesIO
from docker import Client
from pprint import pprint
import sys

cli = Client(base_url="tcp://")
#cli = Client(base_url='unix://var/run/docker.sock')
with open("/path/to/docker-" + GCC_VERSION_TAG + "-gcc-base-image-dockerfile", mode="r") as dockerfile:
  f = BytesIO('utf-8'))
      response = [pprint(line["stream"]) for line in, nocache=False, rm=True, tag='gcc49/toolchain-base_'+GCC_VERSION_TAG, decode=True, pull=True)]
      raise IOError("Invalid Dockerfile!")
  if response != "None":

print "Create container"
container = cli.create_container(image='gcc49/toolchain-base_' + GCC_VERSION_TAG + ':latest',stdin_open=True, tty=True, volumes=['/ssd', '/opt', '/nfs/'], host_config=cli.create_host_config(binds=['/ssd:/ssd:rw','/opt/:/opt:ro','/nfs:/nfs:rw']))
print "Start container"
log_stream_list = []
[log_stream_list.append(l) for l in cli.logs(container, stream=True)]

print "".join(log_stream_list)

My dockerfile looks like this:

FROM ubuntu:16.04
ENV CMAKE_TOOLCHAIN_FILE /path/to/toolchainfile.toolchain
ENV SOURCE_DIR /path/to/src_root
RUN apt-get update 
RUN apt-get install -y python-cheetah build-essential gcc-4.9 cmake
RUN groupadd group
RUN useradd -G group -m -s /bin/bash user 
RUN echo "user:user" | chpasswd
ENV HOME /home/user
ENV SHELL /bin/bash
ENV JAVA_HOME /opt/jdk1.8.0_65/
RUN mkdir -p /home/user/docker-build
WORKDIR /home/user/docker-build
# Set permissions
RUN chown -R user:group /home/*
USER user
# Start build on run

My issue:

15:37:27 [docker-test_job] $ python /tmp/
15:37:29 u'Step 1 : FROM ubuntu:16.04\n'
15:37:29 Traceback (most recent call last):
15:37:29   File "/tmp/", line 15, in <module>
15:37:29     raise IOError("Invalid Dockerfile!")
15:37:29 IOError: Invalid Dockerfile!
15:37:29 Build step 'Execute Python script' marked build as failure
15:37:29 Stopping all containers
15:37:29 Finished: FAILURE

When I try it with ubuntu:14.04 it works pretty fine. Got anyone an idea?
Thanks for helping!

  • Process window not proceeding after reader.ReadLine()
  • Shipping multi-container Docker app
  • Can’t push to docker hub (authentication required)
  • Use Docker with my Ubuntu 14.04 (web access)
  • Which is the right workflow with DBs and Docker
  • How to run nginx with docker container?
  • Update: Some additional information: Docker 1.5 + Ubuntu 12.04 LTS.
    When I run on console

    docker build -t name/tag -f dockerfilename .

    it works too and the docker builds the image as expected.

  • Do Docker images save the memory state?
  • OpenCV error when Docker container is run on GKE
  • How to view the docker image/container limit? And how to modify it while we run “docker build”?
  • Setting up X11 display: One application works while other one don't
  • Change Docker backoff time
  • Which Amazon AMI for a Rails app in a Docker image?
  • 2 Solutions collect form web for “Docker build ubuntu:xenial issue”

    It works now. I figured out that I can’t use pull=True. I think a return code > 0 comes back and Jenkins interpret it as an error. Thanks for any help. 🙂 Below is the code which work.

    [pprint(line["stream"]) for line in, nocache=False, rm=True, tag='gcc49/toolchain-base_'+GCC_VERSION_TAG, decode=True)]


    I was wrong. In upper line I try to match the key “stream”. But if docker pulls the image. There is no such key.

    10:28:06  u'progress': u'[===================================>               ] 36.18 MB/50.84 MB',
    10:28:06  u'progressDetail': {u'current': 36175872, u'total': 50841331},
    10:28:06  u'status': u'Extracting'}

    Now everything is clear. 🙂

    i’m guessing you need to give the path to the Docker file (including the name of your Dockerfile) while in your python script it seems like you are only providing the directory where Dockerfile is present. try changing the part

    open(“/path/to/docker-” + GCC_VERSION_TAG + “-gcc-base-image”, mode=”r”)’


    open(“/path/to/docker-” + GCC_VERSION_TAG + “-gcc-base-image/dockerfilename”, mode=”r”)

    and see if it works

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