Использование докера версии 1.9.0
У меня есть докер-контейнер, предоставляющий доверенное зеркало Ubuntu (trusty-mirror). Я пытаюсь построить второй контейнер и хочу, чтобы он обновлял и устанавливал пакеты из trusty-mirror.
Мой Dockerfile для второго контейнера имеет;
FROM ubuntu:14.04
RUN sed -i -e s#http://archive.ubuntu.com#${MIRROR}#g \
-e s#http://security.ubuntu.com#${MIRROR}#g \
/etc/apt/sources.list
RUN cat /etc/apt/sources.list
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get -y autoremove
Я передаю информацию MIRROR сборке Docker, используя опцию --build-arg, вот так;
ip=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' trusty-mirror 2>/dev/null)
docker build --build-arg MIRROR=ftp://$ip
Когда это работает;
+++ docker inspect --format '{{ .NetworkSettings.IPAddress }}' trusty-mirror
++ ip=172.17.0.2
++ docker build --build-arg MIRROR=ftp://172.17.0.2 .
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.
Обратите внимание, что MIRROR build-arg раскрывается в "", что приводит к повреждению файла /etc /apt sources.list и приводит к сбою обновления.
Я дважды проверил Dockerfile, используя жестко закодированное значение в Dockerfile;
ENV MIRROR=ftp://172.17.0.2
и все работает, как ожидалось, за исключением сборки Docker не удается;
One or more build-args [MIRROR] were not consumed, failing build.
Что мне здесь не хватает?