Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

docker - Interactive command in Dockerfile

I'm trying to automate a creation of a development Docker image using docker build command with appropriate Dockerfile. One of the scripts that I need to run in a RUN command wants the user to click through and read their license agreement. Thus there are two questions:

  1. Where is the output of all the RUN commands in a Dockerfile?
  2. What solution is possible to interact with the aforementioned command? Right now the docker build command just gets stuck asking user for input in an infinite loop.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can also do it in several steps, begin with a Dockerfile with instructions until before the interactive part. Then

docker build -t image1 .

Now just

docker run -it --name image2 image1 /bin/bash

you have a shell inside, you can do your interactive commands, then do something like

docker commit image2 myuser/myimage:2.1

The doc for docker commit

https://docs.docker.com/engine/reference/commandline/commit/

you may need to specify a new CMD or ENTRYPOINT, as stated in the doc

Commit a container with new CMD and EXPOSE instructions

For example some docker images using wine do it in several steps, install wine, then launch and configure the software launched in wine, then docker commit


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...