LoginSignup
11
11

More than 5 years have passed since last update.

DockerでIRCサーバーを立てる using ngircd

Posted at

やること

  • タイトルのまま

動作確認環境

Dockerfile

docker runしてngircd起動状態のコンテナを立ち上げる

  • -dでバックグラウンド実行
    • ngircd自体はフォアグラウンド起動しているので、コンテナのプロセスは終了せずに残る
  • 使用ポートは6667。ホストVMの同じポートにフォワードする
$ docker pull goldeneggg/centos-ngircd
$ docker run -t -d -p 6667:6667 goldeneggg/centos-ngircd

接続確認

  • 作業PCのhostsに下記を追記
<VMのIPアドレス> ngircd.localdomain
  • 作業PCのIRCクライアントから接続
    • サーバー : ngircd.localdomain
    • ポート : 6667
    • チャンネル : #Test
    • ニックネーム等は任意で

他PCからの接続

  • VagrantfileでVM <=> 母艦PC のポートフォワードを設定
  • IRCクライアントのサーバー設定で "母艦PCのIP or 名前" と "フォワードしたポート" を設定すればアクセスできる(はず)

チャネルを増やしたりとか、サーバー名変えたりとか、諸々カスタマイズしたい

$ git clone https://github.com/goldeneggg/dockerfile-centos-ngircd.git
$ cd dockerfile-centos-ngircd
$ vi ADD_FILES/etc/ngircd.conf

$ docker build -t goldeneggg/centos-ngircd:<任意のタグ> .
$ docker run -t -d -p 6667:6667 goldeneggg/centos-ngircd:<任意のタグ>

備考 Vagrantfile

参考までに

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

# VM initialize script
$yum_init = <<SCRIPT
yum update -y
SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "centos65_x86"
  config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box"

  config.vm.define :vmcd do |vmcd|
    vmcd.vm.hostname = "vmcd"

    # network configuration
    vmcd.vm.network :private_network, ip: "192.168.56.110"

    # Dockerで立てたIRCに他PCからも接続させたい場合は、Macの任意のポートに6667をフォワード
#    forward_ports = { 26667 => 6667 }
#    forward_ports.each do |host_port, guest_port|
#      vmcd.vm.network :forwarded_port, host: host_port, guest: guest_port
#    end

    # vm customize
    vmcd.vm.provider :virtualbox do |vb|
      vb.customize ["modifyvm", :id, "--memory", 1024]
    end

    # initialize (provisioner=shell)
    vmcd.vm.provision :shell do |s|
      s.inline = $yum_init
    end

    vmcd.vm.provision :docker do |d|
      d.pull_images "centos"
    end
  end
end
11
11
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
11
11