I think I am doing something a bit too convoluted and hence probably wrong.
So I want to change the /etc/hosts file and to do that, I changed the entrypoint in the Dockerfile to something like
ENTRYPOINT ["/bin/sh", "-c", "echo \"10.0.0.1 some_pc\" >> /etc/hosts && exec \"$@\""]
CMD ["some_reasonable.sh"]
If I set my something_reasonable.sh
to do something useful it, it runs, but if I want to start again the docker image with an interactive shell it just exits. Moreover, if I try to execute a command with arguments, it treats it as 2 commands.
I think there is something wrong with the way I am treating shell and scripts. Probably, putting the exec line like this is not the same as putting in a script (like What does set -e and exec "$@" do for docker entrypoint scripts?)
So how can I write this ENTRYPOINT one-liner so that
docker-run -it my_docker:latest bash
gives me back my interactive session?