Using docker version 1.9.0

I have a docker container providing a ubuntu trusty mirror (trusty-mirror). I am trying to build a second container and want it to update and install packages from trusty-mirror.

My Dockerfile for the second container has;

FROM ubuntu:14.04

RUN sed -i -e s#http://archive.ubuntu.com#${MIRROR}#g \
           -e s#http://security.ubuntu.com#${MIRROR}#g \
RUN cat /etc/apt/sources.list
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get -y autoremove

I pass the MIRROR information to docker build using the --build-arg option, like so;

ip=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' trusty-mirror 2>/dev/null)
docker build --build-arg MIRROR=ftp://$ip

When this runs;

+++ docker inspect --format '{{ .NetworkSettings.IPAddress }}' trusty-mirror
++ ip=
++ docker build --build-arg MIRROR= .
Sending build context to Docker daemon 8.192 kB
Step 1 : FROM ubuntu:14.04
 ---> e9ae3c220b23
Step 2 : RUN sed -i -e s#http://archive.ubuntu.com#${MIRROR}#g            -e s#http://security.ubuntu.com#${MIRROR}#g            /etc/apt/sources.list
 ---> Using cache
 ---> 76f727c60ef8
Step 3 : RUN cat /etc/apt/sources.list
 ---> Running in 55ff5ff46467
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.

deb /ubuntu/ trusty main restricted
deb-src /ubuntu/ trusty main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb /ubuntu/ trusty-updates main restricted
deb-src /ubuntu/ trusty-updates main restricted

## Uncomment the following two lines to add software from the 'universe'
## repository.
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb /ubuntu/ trusty universe
deb-src /ubuntu/ trusty universe
deb /ubuntu/ trusty-updates universe
deb-src /ubuntu/ trusty-updates universe

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb /ubuntu/ trusty-backports main restricted
# deb-src /ubuntu/ trusty-backports main restricted

deb /ubuntu/ trusty-security main restricted
deb-src /ubuntu/ trusty-security main restricted
deb /ubuntu/ trusty-security universe
deb-src /ubuntu/ trusty-security universe
# deb /ubuntu/ trusty-security multiverse
# deb-src /ubuntu/ trusty-security multiverse
 ---> b296354b0b9e
Removing intermediate container 55ff5ff46467
Step 5 : RUN apt-get update
 ---> Running in 7251e0ffb6d2
E: Malformed line 4 in source list /etc/apt/sources.list (URI parse)
E: The list of sources could not be read.

Note the build-arg MIRROR expands to "", which corrupts the /etc/apt sources.list and causes the update to fail.

I have double checked the Dockerfile using a hard coded value in the Dockerfile;


and everything runs as expected, EXCEPT docker build fails with;

One or more build-args [MIRROR] were not consumed, failing build.

What am I missing here?

2 Answers 2


What I missed was the Dockerfile requiring a corresponding ARG entry.


Instead of


You can use


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.