How to specify in Dockerfile that the image is interactive?
Many of the docker run
options can only be specified at the command line or via higher-level wrappers (shell scripts, Docker Compose, Kubernetes, &c.). Along with port mappings and network settings, the “interactive” and “tty” options can only be set at run time, and you can’t force these in the Dockerfile
.
You can use the docker run
command.
docker build -t curly .docker run -it curly curl https://stackoverflow.com
The convention is:
docker run -it IMAGE_NAME [COMMAND] [ARG...]
Where [COMMAND]
is curl
and [ARG...]
are the curl
arguments, which is https://stackoverflow.com
in my example.
-i
enables interactive process mode. You can't specify this in the Dockerfile
.-t
allocates a pseudo-TTY for the container.
Are you looking for the -it
option?
From the Docker documentation:
For interactive processes (like a shell), you must use -i -t together in order to allocate a tty for the container process.
So, for example you can run it like:
docker run -it IMAGE_NAME [COMMAND] [ARG...]