Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The DISPLAY environment variable is missing in Docker image creation #1

Closed
GustavoBorges13 opened this issue Sep 13, 2024 · 1 comment

Comments

@GustavoBorges13
Copy link
Owner

image

@GustavoBorges13
Copy link
Owner Author

🐳 Docker Setup from Docker Hub

To run graphical applications in Docker, you'll need to configure X11 display support based on your operating system.

General Notes

Ensure Docker is installed and configured on your machine.

For Windows Users

If you need to display graphical applications from Docker on Windows, follow these steps:

  1. Download and Install X Server:

    • Install VcXsrv, a Windows X Server tool. This will set up Xming and Xlaunch.
  2. Configure Xlaunch:

    1. Launch Xlaunch after installation.
    2. In the "Select Display Settings" screen, keep "Multiple windows" checked.
    3. In the "Select how to start clients" screen, choose "Start no client".
    4. In the "Extra settings" screen, check "Disable access control".
    5. Click "Finish" to complete the setup.
  3. Run the Docker Container:

    docker run -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 gustavoborges13/vulkan_app
    
    # If you have an NVIDIA GPU (optional), use:
    docker run --gpus all -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 gustavoborges13/vulkan_app

    Xlaunch will run in the background, waiting for X11 applications to connect and use display :0.

For Linux Users

To display graphical applications from Docker on Linux, follow these steps:

  1. Install X Server:

    • Most Linux distributions come with an X server installed. If not, install it using your package manager:

      sudo apt-get install xorg
  2. Configure X Server for Docker:

    • Allow Docker containers to access the X server:

      xhost +local:docker
      
      # To revoke access later (optional):
      xhost -local:docker
  3. Run the Docker Container:

    docker run -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 -v /tmp/.X11-unix:/tmp/.X11-unix gustavoborges13/vulkan_app
    
    # If you have an NVIDIA GPU (optional), use:
    docker run --gpus all -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 -v /tmp/.X11-unix:/tmp/.X11-unix gustavoborges13/vulkan_app

    This setup will allow Docker containers to use the X11 display server on your Linux system.

For macOS Users

To display graphical applications from Docker on macOS, follow these steps:

  1. Install X Server:

    • Download and install XQuartz from the official website.
  2. Configure XQuartz:

    1. Open XQuartz after installation.
    2. Go to XQuartz > Preferences.
    3. In the "Security" tab, check "Allow connections from network clients".
    4. Restart XQuartz to apply the changes.
  3. Run the Docker Container:

    • Run the Docker container:

      docker run -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 gustavoborges13/vulkan_app
      
      # If you have an NVIDIA GPU (optional), use:
      docker run --gpus all -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 gustavoborges13/vulkan_app

    XQuartz will provide the display server necessary for running X11 applications.

Sample usage:
I use windows 11/10.
Open XLaunch.
image
Configure XLaunch.
image
image
image
image
Run the docker app and execute in terminal the command:

 docker run -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 gustavoborges13/vulkan_app
 
 # If you have an NVIDIA GPU (optional), use:
 docker run --gpus all -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 gustavoborges13/vulkan_app

image


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant