制作mqttserver容器docker镜像

(1)根目录下新建mydocker文件夹
#mkdir /mydocker
#cd /mydocker
(2)构建dockerfile
#vim dockerfile_mqttserver

{
FROM centos
WORKDIR /var/apps/mqtt
ADD mosquitto-1.4.5.tar.gz /var/apps/mqtt
ADD paho.mqtt.c.tar.gz /var/apps/mqtt
RUN yum install -y gcc gcc-c++ openssl-devel c-ares-devel libuuid-devel make doxygen
RUN /bin/sh -c ‘cd paho.mqtt.c && make && make html && make install && cd …’
RUN /bin/sh -c ‘cd mosquitto-1.4.5 && make && make install && sed -i “$a user root” mosquitto.conf’
#RUN mosquitto -c ./mosquitto.conf -v
CMD /bin/sh
}

(3)Build生成镜像
#docker build -f dockerfile_mqttserver -t centos_mqttserver .
(4)启动容器并运行mqtt服务器
#docker run -d --name mqttserver centos_mqttserver mosquitto -c
./mosquitto-1.4.5/mosquitto.conf -v

可以看看我的mqtt安装方法

你可能感兴趣的:(docker)