I am trying to compile a "hello world" Rust program inside a Docker container and then remotely debug it using GDBServer and CLion, but I don't think gdbserver
is starting correctly. When I start it, I don't get the "process started" and "listening on port..." messages I expect; I get nothing.
I have successfully done this with a Raspberry Pi on my home network, but can't get it to work when using Docker.
My ultimate goal is to deploy this Docker container on a Digital Ocean droplet and debug remotely from my local machine. For now, I've got Docker running on the local machine.
I am working on a Mac (Mojave), running Docker (v18.09), and spinning up a Docker container that is an image built from Debian with Rust and gdbserver
installed. GDBServer and Rust are installed by:
# install curl (needed to install rust)
apt-get update && apt-get install -y curl gdb g++-multilib lib32stdc++6 libssl-dev libncurses5-dev
# install rust + cargo nightly
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly
I start the container with docker run --rm -it -v $(pwd):/source -p 7777:7777 schickling/rust
which starts up bash
by default.
Once in the container, I compile the Rust program using rustc -g -o ./program ./src/main.rs
which outputs a single file: program
. I can run the program fine (it only outputs Hello World
).
When I run gdbserver localhost:7777 ./program
inside Docker, the terminal just hangs. I've let it sit for 20 minutes. I can't connect to it from CLion, and even ping
doesn't work from my Mac. I've tried adding the --debug
flag which outputs my_waitpid (11, 0x0)
and then hangs. I've also tried :7777
, 127.0.0.1:7777
, and host:7777
. I've tried several different ports.
I'm not sure where my problem is. It may be that GDBServer is running and the issue is in my CLion setup, but I doubt it. I have path mappings setup and target remote args
is tcp:127.0.0.1:7777
. I just get Connection closed
. Symbol File and Sys Root are empty, but that has worked in the past with my Raspberry Pi.