Coder.Haus | Accessing Ports Between Crostini and ChromeOS
We're a family of geeks who live to design scalable software and hardware solutions. We focus on solid, simple designs focused on industry good standard practices.
crostini, chromeOS, chrome, chromebook, acer, linux
15536
post-template-default,single,single-post,postid-15536,single-format-standard,ajax_fade,page_not_loaded,,qode-title-hidden,qode_grid_1300,qode_popup_menu_push_text_top,qode-content-sidebar-responsive,qode-theme-ver-17.2,qode-theme-bridge,disabled_footer_bottom,wpb-js-composer js-comp-ver-5.6,vc_responsive

Accessing Ports Between Crostini and ChromeOS

I recently purchased an Acer Chromebook so I can develop while on the go. My larger, main laptop is bulky. When I’m sitting waiting for my son’s practice to end or need to take a laptop with me along with other gear the Chromebook makes a good companion.

My ultimate goal was to install Linux application support via Crostini, so I could have access to tools like VS Code, Node.JS, Angular and other technologies. While this was quite easy to pull off, my first roadblock was accessing ports between ChromeOS and Crostini.

The way Google pulls off Crostini is by running a Linux container with a light weight Linux install, and performing magic behind the scenes so you can click and launch Linux apps along side your Chrome and Android apps. While this is a neat trick, it poses a problem when you are trying to access a bound port in Crostini from an app or browser in ChromeOS.

An example would be running a Jupyter Notebook on the Linux host and accessing from Chrome on ChromeOS. Your first step is generating your Jupyter config file.  This is as easy as running

jupyter notebook --generate-config

This places a file called jupyter_notebook_config.py in your ~/.jupyter directory.  Open the config file and find the c.NotebookApp.ip line and enter the address as ‘0.0.0.0’. The 0.0.0.0 IP, also known as INADDR_ANY, forces the server or service to bind to any and all addresses available on the host.



 

 

Start up Juypter notebook and you should see something similar to the below. Notice URL line contains “(penguin or 127.0.0.1)” as the hostname.

Now from your browser on ChromeOS, launch into the URL. The URL will take the form of <VM>.linux.test for the default container, or <VM>.<Container>.linux.test for a newly ramped up container. You can also access the server or service using the container IP.

And there you have it! This should work with any server or service you build and run.