I have created a docker container that runs a command line tool. The container is supposed to be interactive. Am I somehow able to specify in the Dockerfile that the container is always started in interactive mode?
For reference this is the dockerfile:
FROM ubuntu:latest
RUN apt-get update && apt-get -y install curl
RUN mkdir adr-tools && \
cd adr-tools && \
curl -L https://github.com/npryce/adr-tools/archive/2.2.0.tar.gz --output adr-tools.tar.gz && \
tar -xvzf adr-tools.tar.gz && \
cp */src/* /usr/bin && \
rm -rf adr-tools
CMD ["/bin/bash"]
EDIT:
I know of the -it
options for the run
command. I'm explicitly asking for a way to do this in the docker file.
EDIT2:
This is not a duplicate of Interactive command in Dockerfile since my question addresses an issue with how arguments specified to docker run
can be avoided in favor of specifying them in the Dockerfile whereas the supposed duplicate addresses an issue of interactive input during the build of the image by docker itself.
Docker Container Interactive Mode for Redis Container We can first start a Redis Docker container in background using the below command. This will basically pull the Redis Docker image from Docker Hub and start up a container running the same. Next, we can get the id of the running container using the below command.
When you are trying to build an image using the docker build command, you can specify the tag along with the image name to build the image with that specific tag. You can use the −t flag to do so.
Most official Docker images have an ENTRYPOINT of /bin/sh or /bin/bash . Even if you do not specify ENTRYPOINT , you may inherit it from the base image that you specify using the FROM keyword in your Dockerfile.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With