modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
23.11k stars 2.59k forks source link

[Magic CLI]: `magic` hangs when run in Docker container with `network_mode: host` #3655

Open josiahls opened 1 week ago

josiahls commented 1 week ago

Issue description

When running the magic CLI inside a Docker container configured with network_mode: host, the magic command hangs indefinitely. This issue occurs specifically when using Docker Compose with network_mode: host. The same command works as expected when:

Running the container with docker run without network_mode: host. Running the container via Docker Compose without network_mode: host. This suggests that magic is encountering an issue when the container shares the host's network stack.

My desired outcome of this would at least be a better error instead of hang, along with some --verbose output that can tell me why the command isn't doing anything.

Steps to reproduce

Create a Dockerfile that installs magic and max:

FROM ubuntu:22.04

# Install dependencies
RUN apt-get update && apt-get install -y \
    curl \
    bash \
    ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Create a user
RUN useradd -ms /bin/bash magic_user
USER magic_user
WORKDIR /home/magic_user

# Install 'magic' tool
RUN curl -ssL https://magic.modular.com/a2c69706-de8f-4d61-9e13-a10682899104 | bash

# Install MAX using 'magic'
RUN /home/magic_user/.modular/bin/magic global install -c https://conda.modular.com/max-nightly -c conda-forge

# Verify 'magic' installation
RUN /home/magic_user/.modular/bin/magic global list

Create a docker-compose.yml file:

version: '3'
services:
  magic_test:
    build: .
    network_mode: host
    entrypoint: bash

Build and run the Docker image:

docker compose build
docker compose run magic_test
/home/magic_user/.modular/bin/magic global list

Version Info

- Provide magic CLI version by pasting the output of `magic --version` magic 0.3.1
- What OS did you install the magic CLI on? ubuntu 22
- If you're on Linux include the flavor and version e.g. Ubuntu 22.04. ubuntu 20
- Include your CPU architecture e.g. x86-64 or arm64. x86
rickysarraf commented 4 days ago

I am facing a similar problem. Similar, because i see it happening on one of my host machines, intermittently. On another machine, magic works reliably. But on my primary host, it often quietly hangs.

Seen with:

@ magic --version
magic 0.3.1 - (based on pixi 0.29.0)

@ lsb_release -a
Distributor ID: Debian
Description:    Debian GNU/Linux trixie/sid
Release:    n/a
Codename:   trixie
No LSB modules are available.

@ uname -a
Linux priyasi 6.11.2-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.11.2-1 (2024-10-05) x86_64 unknown unknown linux