Interactive command in Dockerfile

前端 未结 3 531
梦毁少年i
梦毁少年i 2020-12-09 17:34

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

3条回答
  •  独厮守ぢ
    2020-12-09 18:36

    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

提交回复
热议问题