Please see how ENTRYPOINT
works in Docker. If you pass any command ( as CMD
or like you did with bash), it will run it, so in your case it would be:
"sh", "-c", "touch /root/FILE1" bash
which makes absolutely no sense.
If you want to create a file inside a container and run it as daemon, do it like this:
Dockerfile:
FROM ubuntu
WORKDIR .
RUN apt-get update
RUN apt-get install apache2 -y
COPY fffff.txt /var/www/html/
RUN touch /root/myfile
Build it the same as you did, but run like this:
docker run -it -d first:latest /bin/bash
Beware, it will run your container as a daemon (-d
flag), so it will not go to the container's shell.
If you want to attach to the daemon container, use docker attach <container_id>
(or <container_name>
)