LoginSignup
4
6

More than 5 years have passed since last update.

Dockerコンテナにgdbによるデバッグ環境の構築

Posted at

概要

  • gdbとdebuginfoパッケージを利用したデバッグ環境をDockerコンテナに構築した際のメモです
  • コンテナイメージはCentOS 6.9です

環境

  • macOS Sierra 10.12.6
  • Docker 17.12.0-ce-mac49

コンテナの準備

  • centosイメージのダウンロード
    
    # docker pull centos
    
  • コンテナの起動
    
    # docker run --cap-add=SYS_PTRACE --security-opt="seccomp=unconfined" --name gdbenv centos:centos6.9 /bin/bash
    
  • --cap-add=SYS_PTRACE: コンテナ内からのgdbによるptrace(2)を許可
  • --security-opt="seccomp=unconfined": コンテナ内からのシステムコールの発行に制限を掛けない

必要パッケージのインストール

  • gdbのインストール
    
    # yum -y install gdb
    
  • debuginfoパッケージのインストール
    
    # yum -y install yum-utils
    # debuginfo-install -y file名
    

コマンドのデバッグ


# gdb `which command`
4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6