12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DockerでMosquittoを動かしたメモ

Posted at

これは何?

MQTTブローカーMosquittoをdockerイメージで動かした時のメモです。

dockerイメージのbuild手順

適当に作業ディレクトリを作る

$ mkdir -p docker/mosquitto
$ cd docker/mosquitto

Dockerfileを作る

Dockerfile
FROM ubuntu
MAINTAINER Shin Hiroe <hogehoge@mail.com>

RUN echo "upgrade apt sources"
RUN apt-get update
RUN apt-get upgrade -y

EXPOSE 1883
RUN echo "install Mosquitto"
RUN apt-get install mosquitto -y

Dockerfileをもとにイメージを作る

  • -tオプションでubuntu:mosquittoという名前をつけます
$ docker build -t ubuntu:mosquitto .

ネットワーク設定

はじめてのDocker on Mac OS Xを参考にさせて頂きつつ、VirtualBoxでポートフォワーディングの設定をする。
今回はMQTTの標準ポート1883番を、単純にdockerコンテナの1883番にフォワードします。

コンテナの起動

-p 1883:1883で先ほどVirtualBoxに設定したポートフォワードを指定して起動。

$ docker run -t -p 1883:1883 -i ubuntu:mosquitto mosquitto

1402742115: Warning: Mosquitto should not be run as root/administrator.
1402742115: mosquitto version 0.15 (build date 2013-08-23 19:23:43+0000) starting
1402742115: Opening ipv4 listen socket on port 1883.
1402742115: Opening ipv6 listen socket on port 1883.

rootで起動すべきではないですぞーって言われてますが、一応起動したようです。

12
12
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
12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?