Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install gdbserver package on Alpine Docker image?

I've been trying to install gdbserver package on Alpine Docker image (https://hub.docker.com/_/alpine/)

apk add gdbserver

was giving me this:

ERROR: unsatisfiable constraints: gdbserver (missing): required by: world[gdbserver]

At the same time,

apk add gdb

works just fine. So, what's the correct way to install the gdbserver package on Alpine?

P.S.

apk update has been executed before everything else.

like image 522
user3346684 Avatar asked May 12 '16 12:05

user3346684


2 Answers

Currently it seems that gdbserver is not a package available at the alpine repositories and the gdb package does not contain gdbserver.

But you can install gdb from source which contains gdbserver.

First you will need to install the required packages for the compilation:

apk add --no-cache make
apk add --no-cache linux-headers
apk add --no-cache texinfo
apk add --no-cache gcc
apk add --no-cache g++

then you can install it , downloading the source and compiling it:

wget http://ftp.gnu.org/gnu/gdb/gdb-7.11.tar.xz
tar -xvf gdb-7.11.tar.xz
cd gdb-7.11
./configure --prefix=/usr
make
make -C gdb install

After that you should be able to run gdbserver from the shell.

I have been using this procedure in Docker, with the following dockerfile which also includes a ssh server installation:

FROM alpine
RUN apk update
# we need make and linux-headers to compile gdb
RUN apk add --no-cache make
RUN apk add --no-cache linux-headers
RUN apk add --no-cache texinfo
RUN apk add --no-cache gcc
RUN apk add --no-cache g++
RUN apk add --no-cache gfortran
# install gdb
# RUN apk add --no-cache gdb
RUN mkdir gdb-build ;\
    cd gdb-build;\
    wget http://ftp.gnu.org/gnu/gdb/gdb-7.11.tar.xz;\
    tar -xvf gdb-7.11.tar.xz;\
    cd gdb-7.11;\
    ./configure --prefix=/usr;\
    make;\
    make -C gdb install;\
    cd ..;\
    rm -rf gdb-build/;
# install ssh server support and keys
RUN apk add --no-cache openssh
RUN ssh-keygen -A
like image 90
rulonder Avatar answered Nov 18 '22 03:11

rulonder


With Alpine 3.8 and newer (gdb >= 8.0.1-r6), gdbserver is readily available as part of the gdb package:

https://pkgs.alpinelinux.org/contents?file=gdbserver&path=&name=gdb&branch=v3.8&repo=main&arch=x86_64

like image 3
valiano Avatar answered Nov 18 '22 04:11

valiano