I am trying to install the PlatformIO IDE extension on a code-server v3.0.1 instance hosted in a docker container. I am running Docker Desktop on Windows 10 Pro and accessing code-server using Chrome 80. The extension seems to install fine using the extension manager in code-server, but when I try to open the PlatformIO Home tab, Chrome reports that 127.0.0.1:8010 did not send any data and therefore the PlatformIO Home page is not shown:
I am using the following Dockerfile:
FROM codercom/code-server:3.0.1
USER root
RUN apt-get update && apt-get install -y python3 python3-distutils \
&& rm -rf /var/lib/apt/lists/*
USER coder
EXPOSE 8010
ENTRYPOINT ["dumb-init", "fixuid", "-q", "/usr/local/bin/code-server", "--host", "0.0.0.0", "--auth", "none", "."]
platformio starts a server listening on 127.0.0.1:8010. This is because it usually only needs to be accessible on the same machine when running on the desktop. The catch is that this can't be exposed by Docker, as Docker only maps through to non-loopback addresses.
platformio home supports a --host argument to get it to listen on another interface, so it can be started with --host=0.0.0.0 so that it can be exposed by Docker.
Not sure what the right fix is though. Should platformio know that it's running in a server environment, or should there be some special logic in code-server to handle it?
It'd be nice to get it working out of the box without any custom Dockerfiles involved.
Yeah, seems like we could just access it at <domain>/proxy/8010. I didn't see an option for changing the URL it tries to open though so I'm not sure how we'd make that work. Maybe it's possible to detect a webview opening on 127.0.0.1:port and change it to the proxy domain instead.
Just got this to run on my system will leave this for anyone it may help...
In the PIO terminal on code-server use the command 'pio home --host x.x.x.x --port 8010' where x.x.x.x is the IP of the docker then bridge the docker port to the host like @r0zzy5 showed. You should then have access to the PIO webgui through http://y.y.y.y:8010 where y.y.y.y is the docker host IP
Would it be possible for you to provide reproduction steps using the latest version of code-server? If you need an example, look at our bug report template.
With that, I'd be happy to take a closer look for you.
I currently use a Dockerfile as below to ensure the prerequisites are met for installing the PlatformIO plugin.
FROM ghcr.io/linuxserver/code-server
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends python3 python3-distutils python3-dev python3-pip curl make && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Then ensure that the PlatformIO settings in VScode are set correctly. I.e. set the IP to 0.0.0.0 instead of 127.0.0.1, and make the port static. I have it set to 8010. Then make sure this port is exported when starting the docker container (docker run [...] -p 8010:8010 [...]).
Do note though that only one instance can be opened and linked to PIO at any given time, as only one port can be set to static and each new session requires it's own port.
I'm was experiencing the same issues with effectively the same setup as @utya, except with a compose file. I also tried installing code-server without docker and had similar issues - with enough tinkering I was eventually able to access PIO directly at $LOCAL_IP:8010, but code-server refused to show anything in the extension window.
Just to be clear, my exact symptoms are:
Error message "127.0.0.1 refused to connect" when host was set to 127.0.0.1.
Black (blank?) frame when set to either $LOCAL_IP or 0.0.0.0
Occasionally seeing "Loading..." for a few seconds before the black frame - couldn't pin down what was changing to make that happen.
Setting the port to static or dynamic didn't seem to make a difference.
I had https enabled and working, and the strict SSL option was set to false.
Reacted by Joe Previte, Ihor Nahornyy and Michael Elin
any progress? here I have this message at start, don't know if it is related to this issue:
Error: Traceback (most recent call last):
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 69, in
main()
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 61, in main
bootstrap()
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 47, in bootstrap
pioinstaller.main.main()
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/pioinstaller.zip/pioinstaller/main.py", line 131, in main
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/pioinstaller.zip/click/core.py", line 1137, in call
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/...
Error: Traceback (most recent call last):
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 69, in
main()
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 61, in main
bootstrap()
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 47, in bootstrap
pioinstaller.main.main()
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/pioinstaller.zip/pioinstaller/main.py", line 131, in main
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/pioinstaller.zip/click/core.py", line 1137, in call
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/...
any progress? here I have this message at start, don't know if it is related to this issue:
I am not familiar with this extension or how it works, but if you can write out full repro steps (assume I know nothing...), then I can take a look faster
hi, I have found a solution, but I don't use Docker but Ubuntu directly but should be applicable to a Docker container. Since Platformio sits in an iframe it doesn't work properly if it doesn't refer to 127.0.0.1 I used a caddy server as a proxy and in the visx the pio home server starts at 0.0.0.0 but in the iframe it is taken from the package json and referring to https but always +50 ie the Pio server starts on port 8010 but in the iframe there is https: // IP: 8060 / session / so you can refer to 8010 via the caddy file and there is no mixed content. However, I took a static entry for the session key because I use several PCs. With a dynamic one, "Not found" was always displayed
hi, ich habe eine Lösung gefunden allerdings nutze ich keinen Docker sondern direkt Ubuntu sollte aber auf einen Docker Container anwendbar sein. Da Platformio in einen Iframe sitzt funktioniert es nicht richtig wenn es nicht auf 127.0.0.1 verweist ich habe einen Caddyserver als Proxy genutzt und in der visx startet der pio Home Server auf 0.0.0.0 aber im Iframe wird er eintrag aus der Package json genommen und auf https verwiesen jedoch immer +50 d.h. der Pio Server startet auf Port 8010 aber im Iframe steht dann https://IP:8060/session/ so kann man dann über die Caddyfile von 8060 auf 8010 verweisen und es ist kein gemischter Inhalt. Allerdings habe ich beim Sessionkey einen Statischen Eintrag genommen da ich mehrere PC's verwende bei einem Dynamischen kam immer "Not found"
If I connect a terminal to the code-server container and run
cd /usr/lib/code-server
code-server --install-extension platformio.platformio-ide --force
I get the error logs:
Installing extensions...
Extension 'platformio.platformio-ide' not found.
Make sure you use the full extension ID, including the publisher, e.g.: ms-dotnettools.csharp
Failed Installing Extensions: platformio.platformio-ide
It looks like these code-server docs explain why MS' extension marketplace isn't used and suggest Open VSX.
Closing this out since from what I can tell, this is an extension issue? Instead of using 127.0.0.1 I think they need to use asExternalUri or something like that. But if there is something we need to change in code-server let me know and we can reopen.
It reproduces in Codespaces as well, so it does seem to be an issue with the extension and/or VS Code core.
Activity
x-cubed commented on Apr 4, 2020
I've had a quick look at this.
platformio starts a server listening on 127.0.0.1:8010. This is because it usually only needs to be accessible on the same machine when running on the desktop. The catch is that this can't be exposed by Docker, as Docker only maps through to non-loopback addresses.
platformio home supports a --host argument to get it to listen on another interface, so it can be started with --host=0.0.0.0 so that it can be exposed by Docker.
Not sure what the right fix is though. Should platformio know that it's running in a server environment, or should there be some special logic in code-server to handle it?
It'd be nice to get it working out of the box without any custom Dockerfiles involved.
r0zzy5 commented on Apr 7, 2020
@x-cubed, I agree it would be best if this could "just work" without any custom Dockerfiles.
However for the time being, where would I configure my platformio home to launch using the --host argument?
kylecarbs commented on Apr 7, 2020
We could fix this with the addition of our #1453 feature.
Thoughts @code-asher ?
code-asher commented on Apr 7, 2020
Yeah, seems like we could just access it at <domain>/proxy/8010. I didn't see an option for changing the URL it tries to open though so I'm not sure how we'd make that work. Maybe it's possible to detect a webview opening on 127.0.0.1:port and change it to the proxy domain instead.
justurn commented on May 27, 2020
Just got this to run on my system will leave this for anyone it may help...
In the PIO terminal on code-server use the command 'pio home --host x.x.x.x --port 8010' where x.x.x.x is the IP of the docker then bridge the docker port to the host like @r0zzy5 showed. You should then have access to the PIO webgui through http://y.y.y.y:8010 where y.y.y.y is the docker host IP
plckr commented on Mar 18, 2021
Any update on this?
jsjoeio commented on Mar 19, 2021
@ricreis394 do the solutions above not work for you? If not, we can take a look into this again.
plckr commented on Mar 19, 2021
@jsjoeio when I click to open PlatformIO Home Page, the UI tries to load a frame which is pointer to 127.0.0.1:, which obviously cannot load.
The commands used in command line are as follows:
pio home --host <internal_docker_ip> --port 8010
pio home --host localhost --port 8010
These 2 above loads something, but not completely, using the subsubdomain port like: 8010.code.example.com
jsjoeio commented on Mar 19, 2021
Ah okay! Hmm..I am not familiar with PlatformIO.
Would it be possible for you to provide reproduction steps using the latest version of code-server? If you need an example, look at our bug report template.
With that, I'd be happy to take a closer look for you.
plckr commented on Mar 19, 2021
OS/Web Information
Steps to Reproduce
Expected
It should appear the PIO Home webpage
Actual
Appears 127.0.0.1 refused to connect.
Screenshot
Notes
when I click to open PlatformIO Home Page, the UI tries to load a frame which is pointer to 127.0.0.1:, which obviously cannot load.
The commands used in command line are as follows:
pio home --host <internal_docker_ip> --port 8010
pio home --host localhost --port 8010
These 2 above loads something, but not completely, using the subsubdomain port like: 8010.code.example.com
This issue can be reproduced in VS Code: No
jsjoeio commented on Mar 22, 2021
Awesome! Thanks so much for the detailed repro steps @ricreis394 - we'll take a look at this in the next milestone/sprint!
EDIT: meant to tag you @ricreis394😅
7 remaining items
jsjoeio commented on Apr 23, 2021
That's awesome to hear - thanks for sharing @yqboy!
@RoboMagus let us know if you get a chance to try using that setting option and see if it fixes your issue
RoboMagus commented on Apr 23, 2021
That setting @yqboy mentions is actually a fix of mine that got merged ;)
I'm working on getting it working behind a reverse proxy as well though...
jsjoeio commented on Apr 23, 2021
Oh HA! Totally missed it. Nice :D
Okay well keep us posted.
utya commented on Jun 8, 2021
Please explain me, What should i do to config code server with working platformIO. Now i use caddy, and don't know how to configure
RoboMagus commented on Jun 8, 2021
I currently use a Dockerfile as below to ensure the prerequisites are met for installing the PlatformIO plugin.
Then ensure that the PlatformIO settings in VScode are set correctly. I.e. set the IP to 0.0.0.0 instead of 127.0.0.1, and make the port static. I have it set to 8010. Then make sure this port is exported when starting the docker container (docker run [...] -p 8010:8010 [...]).
Do note though that only one instance can be opened and linked to PIO at any given time, as only one port can be set to static and each new session requires it's own port.
utya commented on Jun 8, 2021
@RoboMagus
make like this
docker run -d
--name=code-server
-e PUID=1000
-e PGID=1000
-e TZ=Europe/London
-e PASSWORD=pass #optional
-e HASHED_PASSWORD= #optional
-e SUDO_PASSWORD=password #optional
-e SUDO_PASSWORD_HASH= #optional
-e PROXY_DOMAIN=domain #optional
-p 8443:8443
-p 8010:8010
-e DOCKER_MODS=linuxserver/mods:code-server-python3
-v /home/utya:/config
--restart unless-stopped
ghcr.io/linuxserver/code-server
change to 0.0.0.0, and doesn't work
rdotts commented on Jun 25, 2021
I'm was experiencing the same issues with effectively the same setup as @utya, except with a compose file. I also tried installing code-server without docker and had similar issues - with enough tinkering I was eventually able to access PIO directly at $LOCAL_IP:8010, but code-server refused to show anything in the extension window.
Just to be clear, my exact symptoms are:
camelator commented on Oct 13, 2021
any progress? here I have this message at start, don't know if it is related to this issue:
Error: Traceback (most recent call last):
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 69, in
main()
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 61, in main
bootstrap()
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 47, in bootstrap
pioinstaller.main.main()
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/pioinstaller.zip/pioinstaller/main.py", line 131, in main
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/pioinstaller.zip/click/core.py", line 1137, in call
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/...
Error: Traceback (most recent call last):
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 69, in
main()
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 61, in main
bootstrap()
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 47, in bootstrap
pioinstaller.main.main()
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/pioinstaller.zip/pioinstaller/main.py", line 131, in main
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/pioinstaller.zip/click/core.py", line 1137, in call
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/...
jsjoeio commented on Oct 28, 2021
I am not familiar with this extension or how it works, but if you can write out full repro steps (assume I know nothing...), then I can take a look faster
chrishdx commented on Nov 20, 2021
hi, I have found a solution, but I don't use Docker but Ubuntu directly but should be applicable to a Docker container. Since Platformio sits in an iframe it doesn't work properly if it doesn't refer to 127.0.0.1 I used a caddy server as a proxy and in the visx the pio home server starts at 0.0.0.0 but in the iframe it is taken from the package json and referring to https but always +50 ie the Pio server starts on port 8010 but in the iframe there is https: // IP: 8060 / session / so you can refer to 8010 via the caddy file and there is no mixed content. However, I took a static entry for the session key because I use several PCs. With a dynamic one, "Not found" was always displayed
hi, ich habe eine Lösung gefunden allerdings nutze ich keinen Docker sondern direkt Ubuntu sollte aber auf einen Docker Container anwendbar sein. Da Platformio in einen Iframe sitzt funktioniert es nicht richtig wenn es nicht auf 127.0.0.1 verweist ich habe einen Caddyserver als Proxy genutzt und in der visx startet der pio Home Server auf 0.0.0.0 aber im Iframe wird er eintrag aus der Package json genommen und auf https verwiesen jedoch immer +50 d.h. der Pio Server startet auf Port 8010 aber im Iframe steht dann https://IP:8060/session/ so kann man dann über die Caddyfile von 8060 auf 8010 verweisen und es ist kein gemischter Inhalt. Allerdings habe ich beim Sessionkey einen Statischen Eintrag genommen da ich mehrere PC's verwende bei einem Dynamischen kam immer "Not found"
platformio-ide alpha.zip
tbhova commented on Apr 10, 2022
My dockerfile posted above has stopped working.
If I connect a terminal to the code-server container and run
I get the error logs:
It looks like these code-server docs explain why MS' extension marketplace isn't used and suggest Open VSX.
PlatformIO has this tracking issue to add itself to Open VSX.
I'm going to continue following these issues, but I'm likely going to switch to a VSCode VM.
melwinek commented on May 24, 2023
Has anyone been able to get PlatformIO running in docker in code-server?
code-asher commented on Jul 11, 2024
Closing this out since from what I can tell, this is an extension issue? Instead of using 127.0.0.1 I think they need to use asExternalUri or something like that. But if there is something we need to change in code-server let me know and we can reopen.
It reproduces in Codespaces as well, so it does seem to be an issue with the extension and/or VS Code core.