JuliaGizmos / Blink.jl

Web-based GUIs for Julia
Other
360 stars 75 forks source link

Can't open window in docker headless even tried xvfb, no-sand-box #243

Open dlintw opened 4 years ago

dlintw commented 4 years ago

I'm runing Arch Linux with these packages installed

In command line shell, I could run electron by 'electron --no-sandbox', here is the command for launch julia

export ELECTRON_PATH=/usr/bin/electron
xvfb-run julia

In the julia, I type in these command

using Blink
w = Window(Dict("webPreferences.sandbox"=>false))

Still got the following error messages

ERROR: IOError: connect: connection refused (ECONNREFUSED)
Stacktrace:
 [1] connect at /build/julia/src/julia-1.3.1/usr/share/julia/stdlib/v1.3/Sockets/src/Sockets.jl:555 [inlined]
 [2] connect(::Sockets.IPv4, ::Int64) at /build/julia/src/julia-1.3.1/usr/share/julia/stdlib/v1.3/Sockets/src/Sockets.jl:541
 [3] #try_connect#5(::Float64, ::Int64, ::typeof(Blink.AtomShell.try_connect), ::Sockets.IPv4, ::Vararg{Any,N} where N) at /home/dlin/.julia/packages/Blink/4FM8Y/src/AtomShell/process.jl:79
 [4] try_connect at /home/dlin/.julia/packages/Blink/4FM8Y/src/AtomShell/process.jl:77 [inlined]
 [5] #init#6(::Bool, ::typeof(Blink.AtomShell.init)) at /home/dlin/.julia/packages/Blink/4FM8Y/src/AtomShell/process.jl:93
 [6] #init at ./none:0 [inlined]
 [7] #shell#9(::Bool, ::typeof(shell)) at /home/dlin/.julia/packages/Blink/4FM8Y/src/AtomShell/process.jl:129
 [8] shell at /home/dlin/.julia/packages/Blink/4FM8Y/src/AtomShell/process.jl:127 [inlined]
 [9] #Window#14(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Type{Window}, ::Dict{String,Bool}) at /home/dlin/.julia/packages/Blink/4FM8Y/src/AtomShell/window.jl:89
 [10] Window(::Dict{String,Bool}) at /home/dlin/.julia/packages/Blink/4FM8Y/src/AtomShell/window.jl:89
 [11] top-level scope at REPL[6]:1
twavv commented 4 years ago

I can reproduce this using the Julia 1.3 image.

docker run --rm -it julia:1.4

# At container prompt
apt update && apt install -y unzip xvfb
julia -e 'using Pkg; Pkg.add("Blink")'
julia -e 'using Blink; w = Window()'
adrien-le-franc commented 3 years ago

Hi, I had a similar problem and I found the following workaround: you can open a window in your browser, similar to what people do for reading a jupyter notebook from docker.

First, start docker with

docker run --rm -it -p 8700:8700 julia:1.4

then in the Julia prompt, start the server as follows:

using Sockets
using MeshCat
vis = Visualizer(MeshCat.CoreVisualizer(ip"0.0.0.0", 8700), ["meshcat"])

you should be able to reach the url at http://localhost:8700/