I want to use the rsub package for Sublime Text, in order to edit code inside a Docker container which runs on a remote server. However when I execute
rsub my_code.py
I get the error:
/usr/local/bin/rsub: connect: Cannot assign requested address
/usr/local/bin/rsub: line 392: /dev/tcp/localhost/52698: Cannot assign requested address
Line 392 basically corresponds to this instruction:
exec 3<> "/dev/tcp/localhost/52698"
bash: connect: Cannot assign requested address
bash: /dev/tcp/localhost/52698: Cannot assign requested address
If I exit the Docker container and run the same instruction on the remote server, it works nicely (or at least it doesn't give me any error messages). Can you help me fix this problem? I can modify the Dockerfile if needed. I can also post it here if you think it's needed, but I should doctor it a bit before to remove sensitive information.
EDIT: I include the part of the rsub
script which raises the error. Note that at this point in the script, $host=localhost
and $port=52698
. I double checked that with echo
statements.
# connect to textmate and send command
#
exec 3<> "/dev/tcp/$host/$port"
if [ $? -gt 0 ]; then
echo "Unable to connect to TextMate on $host:$port"
exit 1
fi
read -r server_info 0<&3
log $server_info
for i in "${!filepaths[@]}"; do
open_file "$i"
done
echo "." 1>&3
if [[ $nowait = true ]]; then
exec </dev/null >/dev/null 2>/dev/null
( (handle_connection &) &)
else
handle_connection
fi
EDIT:I've been asked about the host OS. This is the result of uname -a
when on the remote host, and outside the Docker container (server name removed):
Linux xxxxxxx 4.4.0-104-generic #127-Ubuntu SMP Mon Dec 11 12:16:42 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
and this is the result of the same command when run inside the Docker container:
Linux yyyyyyyyy 4.4.0-104-generic #127-Ubuntu SMP Mon Dec 11 12:16:42 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
xxxxxxx
and yyyyyyy
are different strings. Also, when inside the Docker container, I can't find any directory tcp
inside the dev
directory:
root@7f199087c883:~# ls /dev/tcp
ls: cannot access '/dev/tcp': No such file or directory
/dev/tcp/localhost
. I'll bet the chances are there isn't one, and that this is a Docker-specific issue. Since I don't know the host OS in this equation (assuming Ubuntu), I can't give you any suggestions of where to look next, other than the standard "'It's a docker and how its containers work' problem." response :/