Может быть, этот подход полезен для вас:
Пример dockerfile
FROM ubuntu
ENV APP ${APP}
RUN apt-get install ${APP}
Затем вы можете выполнить следующую команду:
$ docker build --build-arg APP=tmux .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM ubuntu
---> d55e68e6cc9c
Step 2 : ARG APP
---> Using cache
---> 8331d5368631
Step 3 : ENV APP ${APP}
---> Using cache
---> 7bcd5ac4cbb7
Step 4 : RUN apt-get install -y ${APP}
---> Running in fa0ed50f6ab9
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
libevent-2.0-5
The following NEW packages will be installed:
libevent-2.0-5 tmux
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 373 kB of archives.
After this operation, 895 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main libevent-2.0-5 amd64 2.0.21-stable-1ubuntu1 [126 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty/main tmux amd64 1.8-5 [247 kB]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin:
Fetched 373 kB in 2s (142 kB/s)
Selecting previously unselected package libevent-2.0-5:amd64.
(Reading database ... 11542 files and directories currently installed.)
Preparing to unpack .../libevent-2.0-5_2.0.21-stable-1ubuntu1_amd64.deb ...
Unpacking libevent-2.0-5:amd64 (2.0.21-stable-1ubuntu1) ...
Selecting previously unselected package tmux.
Preparing to unpack .../archives/tmux_1.8-5_amd64.deb ...
Unpacking tmux (1.8-5) ...
Setting up libevent-2.0-5:amd64 (2.0.21-stable-1ubuntu1) ...
Setting up tmux (1.8-5) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
---> 36175c4fdd16
Removing intermediate container fa0ed50f6ab9
Successfully built 36175c4fdd16
В этом конкретном случае мы определяем, какой пакет мы хотите установить время сборки.
Работает с версии 1.9
. Вы можете посмотреть the documentation
Да. Возможно. –
Im новый для докеров, не могли бы вы посоветовать мне, как его реализовать? – user2439278
Во-первых, вы должны знать, как создавать файлы докеров вручную. Во-вторых, вы должны иметь возможность программировать. Затем объедините эти две способности. –