+1 vote

What Linux distribution would you suggest?
What needs to be pre-installed on Linux before exported application can run?

Notes: This is not CRLF problem. I am using latest Alpine Linux for Docker on Windows 10 Pro.

Take "Websocket Chat" demo for example and add code to start listening on node ready signal.

Export project for Linux platform:

websocket_chat.pck
websocket_chat.x86_64

Go to the export folder and create a file "Dockerfile" with content:

FROM alpine
WORKDIR /usr/src/websocket_chat/bin
COPY . /usr/src/websocket_chat/bin
EXPOSE 8000
ENV PORT 8000
ENV PATH=/usr/src/websocket_chat/bin:$PATH
CMD ["ls","-lR"]

Build image:

docker build --tag websocket_chat .

Run container:

docker run -p 8000:8000 websocket_chat

.: total 41904
-rwxr-xr-x    1 root     root         64176 Oct 11 17:45 websocket_chat.pck
-rwxr-xr-x    1 root     root      42843039 Oct 11 17:45 websocket_chat.x86_64

If you replace the last row in file Dockerfile with:

CMD ["websocket_chat.x86_64", ""]

standard_init_linux.go:211: exec user process caused "no such file or directory"

Error describes that command executed inside a container returned "no such file or directory" but it could be caused by many reasons. Also if the process can not start at all. We need to know what needs to be pre-installed on Linux to run Godot exported applications on Linux platform.

in Engine by (34 points)

5 Answers

0 votes

If you need to export to a Linux distro, you don't really need include anything; most of the dependencies are built into the exported executable binary. Unless you're using an obscure Linux distro, it should run without a docker container. If you're targeting Alpine Linux, and the export template for Linux doesn't work, you can build the export template on Alpine.

by (2,014 points)

If you really need to use a docker container, then the problem is that the shell (or whatever docker is using to execute the program) in the docker container can't find the file "websocketchat.x8664". Maybe you need to replace the command with something like CMD ["./websocket_chat.x86_64", ""]?

0 votes

Thank you for your interest as specifics on this topic are hard to find. Docker native environment is Linux. WSL2 is not exactly bare metal and it has limits in functionality. But the question is - can Godot application (1 empty scene - as I am testing atm.) run in Docker container on Windows and what is needed to achieve this.

More information about environment:

Windows 10 Professional (x64):
Docker Desktop Edition (latest): https://docs.docker.com/docker-for-windows/install/
Windows Subsystem for Linux (WSL2): https://docs.microsoft.com/en-us/windows/wsl/install-win10

How to route graphical interface from Linux container via X-server to Windows desktop: https://medium.com/better-programming/running-desktop-apps-in-docker-43a70a5265c4

It is possible (easy) to route Firefox or other native Linux application (not Godot exported binary) with this approach:

You need to install X-server on Windows like VcXSrv:
https://sourceforge.net/projects/vcxsrv/

Dockerfile

FROM alpine
RUN apk update
RUN apk add xfce4
RUN apk add xfce4-terminal
RUN apk add xfce4-screensaver
RUN apk add lightdm-gtk-greeter
RUN apk add dbus-x11
RUN apk add sudo
RUN apk add xf86-video-qxl
RUN apk add xf86-video-fbdev
RUN apk add xf86-input-mouse xf86-input-keyboard
RUN apk add kbd
RUN apk add firefox
CMD ["firefox"]

Build image:

docker build --tag multiplayer_server .

Run image:

docker run --rm -ti -e DISPLAY=host.docker.internal:0 multiplayer_server

VcXSrv streams "video" of running application from container instance. Many applications work like that - godot binary does not. Can anyone provide any additional information - other than you can do this differently - cause I know that.

If you want to run image instance and play with it interactively run image like:

docker run --rm -ti -e DISPLAY=host.docker.internal:0 multiplayer_server /bin/sh

This will open sh (terminal) as root user on running instance. You can then type:

startxfce4

This opens x11 server (graphical desktop). If you browse to folder where you deployed your godot application the exception is the same as provided in my first question.

by (34 points)
0 votes

See Exporting for dedicated servers in the documentation.

Note that if you want to use an Alpine Linux container, you need to use a glibc version. Official binaries are linked against glibc, not musl.

by (10,303 points)
0 votes

Compiling headless or server godot on WSL2 is not possible due to many missing kernel functionality so I had to switch to Linux machine with Ubuntu 18.04.5 LTS.

Noticed that regular version of Godot (native build) under Linux and if you have AMD graphic card requires support and installed/working drivers for Vulcan. If anyone knows more details about this requirements please let me know. And I did have to use stable version 3.2 from Github as Master failed to build - related maybe:

AttributeError: 'SConsEnvironment' object has no attribute 'GLSL_HEADER'

I deployed a simple game (2d gallery) to docker container as a .x86_64 file (it was exported on Windows for Linux platform) and got an error:

error while loading shared libraries: libXcursor.so.1: cannot open shared object file: No such file or directory

Its probably the fact that the base ubuntu image used for container does not have X11 server. The game has GUI as in rendered scenes so its kind of expected that it does not work in container. The .x86_64 binary does work however in native Ubuntu OS on X11 server (Desktop GUI).

For dedicated server you need to make Godot server build on same Linux distribution you will be using for Docker contaner. Your "server code" can be executed in multiple ways.

As Godot server binary and project PCK file as input parameter:

./godot_server.x11.opt.64 --verbose --main-pack ./mygodotproject.pck

Docker image build folder:
godot_server.x11.opt.64
mygodotproject.pck
Dockerfile

Dockerfile (content)

FROM ubuntu
COPY . /usr/app/
WORKDIR /usr/app/
CMD ./godot_server.x11.opt.64 --verbose --main-pack ./mygodotproject.pck

As Godot server binary and project folder as input parameter:

./godot_server.x11.opt.64 --verbose --path ./mygodotprojectfolder

Docker image build folder:
godot_server.x11.opt.64
mygodotproject (your Godot project folder)
Dockerfile

Dockerfile (content)

FROM ubuntu
COPY . /usr/app/
WORKDIR /usr/app/
CMD ./godot_server.x11.opt.64 --verbose --path ./mygodotprojectfolder

The build process for headless and server build is documented here.

by (34 points)
edited by
0 votes

So what are the dependencies for running Linux container (any container) in Docker:

It depends on:
- docker host operating system,
- operating system you are using for docker image
- and application you are trying to run in docker container.

Host system libraries are used in runtime by docker containers if they are of the same operating system. Otherwise you must provide all of the required libraries when building docker image. That was my original question regarding Godot application.

So what does Godot aplication need to run in docker container?

For a dedicated server you will be looking at headless/server build of Godot. Possible even custom build to reduce size.

Example docker image:
Godot server built with gcc without tools is around 126MB,
Alpine base image is 6MB.
You need to install additional libraries
- gcc or clang
- libexecinfo (Android, Alpine Linux specific)
that is 260MB.
Without your application: 392MB
Add in your application pck to get the final size.

For example you can strip debug symbols from Godot server with:

strip godot_server.x11.opt.debug.64.llvm

and reduce the size from 126MB to 44MB.

If you use Alpine OS (same OS) as host for Docker you can share kernel libraries between docker containers so they do not need to be built-in. That would make Godot around 44MB + your application pck. Dedicated network only server would probably reduce the size even more - todo list.

If anyone has problems building on Alpine Linux read this post on forum:
https://godotforums.org/discussion/24458/linker-fails-handle-crash-int-godot-3-x-on-alpine-linux-3-12#latest

In short:

apk add libexecinfo-dev
scons -j8 platform=server use_llvm=yes tools=no target=release_debug verbose=yes LINKFLAGS=-lexecinfo
by (34 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.