0

I'm trying to run a visual studio server and create a dockerfile. If you want to reproduce the script clone https://github.com/alessandriLuca/4Stackoverflow . script.sh will build the docker container and run it sharing the port. The problem is that apparently i cant reach the port 8080 even if i exposed it. I solved on ubuntu with --network host but this option is not accessible for OsX or Windows.

Here is the last part of the dockerfile, that is related to visualStudio installation

COPY visualStudio /visualStudio
RUN cd /visualStudio/ && 7za -y x "*.7z*"
RUN dpkg -i /visualStudio/visualStudio/*.deb
COPY config.yaml ~/.config/code-server/config.yaml
EXPOSE 8080
CMD ["code-server","--auth","none"]

As you can see i use a config.yaml but that one is also not working since when i run the code-server that file is overwritten so, the port still remain 8080.

Thank you for any help

EDIT You can find all files, included config.yaml here https://github.com/alessandriLuca/4Stackoverflow/tree/main/merged2_visualStudio

EDIT I kind of solved it! Practically as you said was hosting on 127.0.0.1 instead of 0.0.0.0, soo i changed manually in config.yaml and now is working. The only problem now is to add this configuration directly in the dockerfile since, when I run the server he overwrite the config.yaml that I created. Does someone have any idea about this part?

  • The EXPOSE statement doesn't do anything except document what ports the author of the image thinks the container listens on. It can be wrong and you won't get any errors. What's important is what port the code-server program actually listens on. I tried looking briefly at the docs, but couldn't find that info. – Hans Kilian Feb 02 '22 at 11:08
  • oh ok, I thought was a command as written here https://www.geeksforgeeks.org/docker-expose-instruction/ –  Feb 02 '22 at 11:24
  • It says "It is also important to understand that the EXPOSE instruction only acts as an information platform (like Documentation) between the creator of the Docker image and the individual running the Container", but that's easy to overlook. The first sentences indicates that it's doing more than it actually is. – Hans Kilian Feb 02 '22 at 11:38
  • Did you publish the port? Is the app listening on all interfaces or only localhost? – BMitch Feb 02 '22 at 11:45
  • A [mcve] should not require privileged or mounting the docker socket. Ref from your script: `​docker run -itv ​$tt​:/home/visualStudio/ -v /var/run/docker.sock:/var/run/docker.sock --cidfile  ​$tt​/id.txt --privileged=true -p 8080:8080 -e DISABLE_AUTH=true rstudio` – BMitch Feb 02 '22 at 11:49
  • Can you edit the question to include enough of your application code to show how you're setting up the network listener? What you describe sounds like the symptom of an application that only listens on `127.0.0.1` and not `0.0.0.0`, which is a code- or configuration-level change and not something you'd usually see in the Docker-level setup. – David Maze Feb 02 '22 at 14:47
  • You are a genious!!! I kind of solved it! Practically as you said was hosting on 127.0.0.1 instead of 0.0.0.0, soo i changed manually in config.yaml and now is working. The only problem now is to add this configuration directly in the dockerfile since, when I run the server he overwrite the config.yaml that I created. –  Feb 02 '22 at 22:10

0 Answers0