Cannot assign address inside a Docker container

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
2
down vote

favorite












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






share|improve this question






















  • it's actually a Perl script. I'm very bad with Perl...I can post the whole script, but I won't probably be able to create a MVE without someone else's help. Unfortunately the Perl whiz left...
    – DeltaIV
    May 17 at 17:05











  • I added the part of the Perl script, from the command which raises the error to the end. I can include the rest, if you want. It's about 400 lines, though.
    – DeltaIV
    May 17 at 17:08






  • 1




    Just a consideration, Docker containers are typically not "full OS" containers (like LXD or OpenVZ based VPSes are), and binding to ports might not behave the same way with them. As such, you may get it to work fine on the 'remote' host, but you might not be able to get it working on remote docker containers (which sit 'within' the host and have a NAT component).
    – Thomas Ward♦
    May 18 at 16:07











  • @ThomasWard indeed, it works fine on the 'remote' host when I'm outside the Docker container, as you predicted.
    – DeltaIV
    May 18 at 16:14










  • Keep in mind that with Docker, to bind to a port it's supposed to be configured in Docker container at runtime what ports are to be bound with. This said, if you can go into the Docker container, see if there's anything at /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 :/
    – Thomas Ward♦
    May 18 at 16:16















up vote
2
down vote

favorite












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






share|improve this question






















  • it's actually a Perl script. I'm very bad with Perl...I can post the whole script, but I won't probably be able to create a MVE without someone else's help. Unfortunately the Perl whiz left...
    – DeltaIV
    May 17 at 17:05











  • I added the part of the Perl script, from the command which raises the error to the end. I can include the rest, if you want. It's about 400 lines, though.
    – DeltaIV
    May 17 at 17:08






  • 1




    Just a consideration, Docker containers are typically not "full OS" containers (like LXD or OpenVZ based VPSes are), and binding to ports might not behave the same way with them. As such, you may get it to work fine on the 'remote' host, but you might not be able to get it working on remote docker containers (which sit 'within' the host and have a NAT component).
    – Thomas Ward♦
    May 18 at 16:07











  • @ThomasWard indeed, it works fine on the 'remote' host when I'm outside the Docker container, as you predicted.
    – DeltaIV
    May 18 at 16:14










  • Keep in mind that with Docker, to bind to a port it's supposed to be configured in Docker container at runtime what ports are to be bound with. This said, if you can go into the Docker container, see if there's anything at /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 :/
    – Thomas Ward♦
    May 18 at 16:16













up vote
2
down vote

favorite









up vote
2
down vote

favorite











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






share|improve this question














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








share|improve this question













share|improve this question




share|improve this question








edited May 18 at 16:29

























asked May 17 at 16:58









DeltaIV

1314




1314











  • it's actually a Perl script. I'm very bad with Perl...I can post the whole script, but I won't probably be able to create a MVE without someone else's help. Unfortunately the Perl whiz left...
    – DeltaIV
    May 17 at 17:05











  • I added the part of the Perl script, from the command which raises the error to the end. I can include the rest, if you want. It's about 400 lines, though.
    – DeltaIV
    May 17 at 17:08






  • 1




    Just a consideration, Docker containers are typically not "full OS" containers (like LXD or OpenVZ based VPSes are), and binding to ports might not behave the same way with them. As such, you may get it to work fine on the 'remote' host, but you might not be able to get it working on remote docker containers (which sit 'within' the host and have a NAT component).
    – Thomas Ward♦
    May 18 at 16:07











  • @ThomasWard indeed, it works fine on the 'remote' host when I'm outside the Docker container, as you predicted.
    – DeltaIV
    May 18 at 16:14










  • Keep in mind that with Docker, to bind to a port it's supposed to be configured in Docker container at runtime what ports are to be bound with. This said, if you can go into the Docker container, see if there's anything at /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 :/
    – Thomas Ward♦
    May 18 at 16:16

















  • it's actually a Perl script. I'm very bad with Perl...I can post the whole script, but I won't probably be able to create a MVE without someone else's help. Unfortunately the Perl whiz left...
    – DeltaIV
    May 17 at 17:05











  • I added the part of the Perl script, from the command which raises the error to the end. I can include the rest, if you want. It's about 400 lines, though.
    – DeltaIV
    May 17 at 17:08






  • 1




    Just a consideration, Docker containers are typically not "full OS" containers (like LXD or OpenVZ based VPSes are), and binding to ports might not behave the same way with them. As such, you may get it to work fine on the 'remote' host, but you might not be able to get it working on remote docker containers (which sit 'within' the host and have a NAT component).
    – Thomas Ward♦
    May 18 at 16:07











  • @ThomasWard indeed, it works fine on the 'remote' host when I'm outside the Docker container, as you predicted.
    – DeltaIV
    May 18 at 16:14










  • Keep in mind that with Docker, to bind to a port it's supposed to be configured in Docker container at runtime what ports are to be bound with. This said, if you can go into the Docker container, see if there's anything at /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 :/
    – Thomas Ward♦
    May 18 at 16:16
















it's actually a Perl script. I'm very bad with Perl...I can post the whole script, but I won't probably be able to create a MVE without someone else's help. Unfortunately the Perl whiz left...
– DeltaIV
May 17 at 17:05





it's actually a Perl script. I'm very bad with Perl...I can post the whole script, but I won't probably be able to create a MVE without someone else's help. Unfortunately the Perl whiz left...
– DeltaIV
May 17 at 17:05













I added the part of the Perl script, from the command which raises the error to the end. I can include the rest, if you want. It's about 400 lines, though.
– DeltaIV
May 17 at 17:08




I added the part of the Perl script, from the command which raises the error to the end. I can include the rest, if you want. It's about 400 lines, though.
– DeltaIV
May 17 at 17:08




1




1




Just a consideration, Docker containers are typically not "full OS" containers (like LXD or OpenVZ based VPSes are), and binding to ports might not behave the same way with them. As such, you may get it to work fine on the 'remote' host, but you might not be able to get it working on remote docker containers (which sit 'within' the host and have a NAT component).
– Thomas Ward♦
May 18 at 16:07





Just a consideration, Docker containers are typically not "full OS" containers (like LXD or OpenVZ based VPSes are), and binding to ports might not behave the same way with them. As such, you may get it to work fine on the 'remote' host, but you might not be able to get it working on remote docker containers (which sit 'within' the host and have a NAT component).
– Thomas Ward♦
May 18 at 16:07













@ThomasWard indeed, it works fine on the 'remote' host when I'm outside the Docker container, as you predicted.
– DeltaIV
May 18 at 16:14




@ThomasWard indeed, it works fine on the 'remote' host when I'm outside the Docker container, as you predicted.
– DeltaIV
May 18 at 16:14












Keep in mind that with Docker, to bind to a port it's supposed to be configured in Docker container at runtime what ports are to be bound with. This said, if you can go into the Docker container, see if there's anything at /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 :/
– Thomas Ward♦
May 18 at 16:16





Keep in mind that with Docker, to bind to a port it's supposed to be configured in Docker container at runtime what ports are to be bound with. This said, if you can go into the Docker container, see if there's anything at /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 :/
– Thomas Ward♦
May 18 at 16:16











1 Answer
1






active

oldest

votes

















up vote
2
down vote













In the end, since rsub was working on the remote host, the simplest solution was to:



  • log on to the remote host (without starting the container)

  • use rsub to edit any files on the remote host, in a session of Sublime on my local pc

  • then build the container again.

It's a bit slow, because each time I make changes I need to rebuild, but:



  • the remote host has a lot of computational power, so rebuilding is quick;

  • it's a better way to work anyway: each time I commit changes to the project, I should rebuild the container anyway. This prompts me to commit changes more often, which is always a good idea :-)





share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1037474%2fcannot-assign-address-inside-a-docker-container%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    In the end, since rsub was working on the remote host, the simplest solution was to:



    • log on to the remote host (without starting the container)

    • use rsub to edit any files on the remote host, in a session of Sublime on my local pc

    • then build the container again.

    It's a bit slow, because each time I make changes I need to rebuild, but:



    • the remote host has a lot of computational power, so rebuilding is quick;

    • it's a better way to work anyway: each time I commit changes to the project, I should rebuild the container anyway. This prompts me to commit changes more often, which is always a good idea :-)





    share|improve this answer
























      up vote
      2
      down vote













      In the end, since rsub was working on the remote host, the simplest solution was to:



      • log on to the remote host (without starting the container)

      • use rsub to edit any files on the remote host, in a session of Sublime on my local pc

      • then build the container again.

      It's a bit slow, because each time I make changes I need to rebuild, but:



      • the remote host has a lot of computational power, so rebuilding is quick;

      • it's a better way to work anyway: each time I commit changes to the project, I should rebuild the container anyway. This prompts me to commit changes more often, which is always a good idea :-)





      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        In the end, since rsub was working on the remote host, the simplest solution was to:



        • log on to the remote host (without starting the container)

        • use rsub to edit any files on the remote host, in a session of Sublime on my local pc

        • then build the container again.

        It's a bit slow, because each time I make changes I need to rebuild, but:



        • the remote host has a lot of computational power, so rebuilding is quick;

        • it's a better way to work anyway: each time I commit changes to the project, I should rebuild the container anyway. This prompts me to commit changes more often, which is always a good idea :-)





        share|improve this answer












        In the end, since rsub was working on the remote host, the simplest solution was to:



        • log on to the remote host (without starting the container)

        • use rsub to edit any files on the remote host, in a session of Sublime on my local pc

        • then build the container again.

        It's a bit slow, because each time I make changes I need to rebuild, but:



        • the remote host has a lot of computational power, so rebuilding is quick;

        • it's a better way to work anyway: each time I commit changes to the project, I should rebuild the container anyway. This prompts me to commit changes more often, which is always a good idea :-)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 18 at 17:45









        DeltaIV

        1314




        1314






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1037474%2fcannot-assign-address-inside-a-docker-container%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491