Guest User

Untitled

a guest
Jan 28th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.26 KB | None | 0 0
  1. FROM schachr/raspbian-stretch:latest
  2.  
  3. docker run -d --net=host
  4. -e "FQDN=mqtt.example.com"
  5. -e "EMAIL=me@example.com"
  6. -e "DOMAIN=example.com"
  7. -e "IPLIST=172.16.16.16 192.168.1.254"
  8. -e "HOSTLIST=somehost.example.com docker.example.com"
  9. -v /home/admin/mosquitto/conf.d:/etc/mosquitto/conf.d:z
  10. -t mosibi/mosquitto
  11.  
  12. System error: exec format error
  13.  
  14. FROM schachr/raspbian-stretch:latest
  15.  
  16. MAINTAINER admin <admind@example.com>
  17.  
  18. ENV LC_ALL="C"
  19. LANG="en_US.UTF-8"
  20. TZ="Asia/Tokyo"
  21.  
  22.  
  23. WORKDIR /tmp
  24.  
  25. # Configure no init scripts to run on package updates.
  26. ADD files/policy-rc.d /usr/sbin/policy-rc.d
  27. RUN chmod 755 /usr/sbin/policy-rc.d &&
  28. : dash を bash に変更 &&
  29. ln -f /bin/bash /bin/sh &&
  30. apt update &&
  31. apt install -y rename openssl
  32. mosquitto mosquitto-clients &&
  33. : mosquitto フォルダを空にする &&
  34. rm -rf /etc/mosquitto &&
  35. mkdir /etc/mosquitto
  36.  
  37. # COPY files
  38. COPY volume /etc/mosquitto/
  39. COPY files/generate-CA.sh /usr/local/bin/generate-CA.sh
  40. COPY files/init /init
  41. RUN chmod 755 /usr/local/bin/generate-CA.sh &&
  42. chmod 755 /init
  43.  
  44. # generate-CA.sh 実行時のディレクトリ
  45. WORKDIR /etc/mosquitto/.ca
  46.  
  47. # MQTT ports
  48. #EXPOSE 1883
  49. EXPOSE 8883
  50. EXPOSE 9001
  51.  
  52. CMD [ "/init" ]
  53.  
  54. $HOME/SmartHome/
  55. ├─ README.md
  56. └─ docker
  57.    └── mosquitto
  58.       ├── Dockerfile
  59.       ├── files
  60.       │   ├── generate-CA.sh
  61.       │   ├── init
  62.       │   └── policy-rc.d
  63.       └── volume
  64.       ├── ca_certificates
  65.       │   └── mqtt_ca.crt
  66.       ├── certs
  67.       │   ├── mqtt_srv.crt
  68.       │   └── mqtt_srv.key
  69.       ├── conf.d
  70.       │   ├── mosquitto.conf
  71.       │   └── websockets.conf
  72.       ├── mosquitto.conf
  73.       ├── mosquitto.conf.example
  74.       └── password.txt
  75.  
  76. $ cd SmartHome/docker/mosquitto
  77. $ docker build -t admin/mosquitto .
  78. $ docker run -it -d --name mosquitto --net=host
  79. -e "FQDN=pi.example.us"
  80. -e "EMAIL=me@example.com"
  81. -e "DOMAIN=example.com"
  82. -e "IPLIST=192.168.0.220 172.20.10.220"
  83. -e "HOSTLIST=pi pi.local pi.example.us 192.168.0.220 172.20.10.220"
  84. -v /home/admin/SmartHome/docker/mosquitto/volume:/etc/mosquitto
  85. -t admin/mosquitto
  86. $ docker ps -a
  87. ・・・ Exited (1) 10 seconds ago
  88.  
  89. $ docker logs mosquitto
  90. /etc/mosquitto/.ca
  91. Generating a RSA private key
  92. ...............+++++
  93. ................................................+++++
  94. writing new private key to './ca.key'
  95. -----
  96. Created CA certificate in ./ca.crt
  97. subject=
  98. commonName = MQTT Broker example.com
  99. organizationName = example.com
  100. emailAddress = me@example.com
  101. Warning: the CA key is not encrypted; store it safely!
  102. --- Creating server key and signing request
  103. Generating RSA private key, 2048 bit long modulus
  104. ..+++++
  105. .....................................................................+++++
  106. e is 65537 (0x010001)
  107. --- Creating and signing server certificate
  108. Signature ok
  109. subject=CN = pi.example.us, O = example.com, emailAddress = me@example.com
  110. Getting CA Private Key
  111. total 28
  112. -rw-r--r-- 1 1000 1000 21 Jan 28 16:00 .gitkeep
  113. -r--r--r-- 1 root root 1281 Jan 28 16:07 mqtt_ca.crt
  114. -r-------- 1 root root 1704 Jan 28 16:07 mqtt_ca.key
  115. -rw-r--r-- 1 root root 17 Jan 28 16:07 mqtt_ca.srl
  116. -r--r--r-- 1 root root 1891 Jan 28 16:07 mqtt_srv.crt
  117. -rw-r--r-- 1 root root 968 Jan 28 16:07 mqtt_srv.csr
  118. -r-------- 1 root root 1679 Jan 28 16:07 mqtt_srv.key
  119. /etc/mosquitto/
  120. total 60
  121. drwxr-xr-x 2 1000 1000 4096 Jan 28 16:07 .ca
  122. drwxr-xr-x 2 1000 1000 4096 Jan 28 16:07 ca_certificates
  123. drwxr-xr-x 2 1000 1000 4096 Jan 28 16:07 certs
  124. drwxr-xr-x 2 1000 1000 4096 Jan 28 16:00 conf.d
  125. -rw-r--r-- 1 1000 1000 750 Jan 28 16:00 mosquitto.conf
  126. -rw-r--r-- 1 1000 1000 33112 Jan 28 16:00 mosquitto.conf.example
  127. -rw-r--r-- 1 1000 1000 115 Jan 28 16:00 password.txt
  128. /etc/mosquitto/ca_certificates/
  129. total 8
  130. -rw-r--r-- 1 1000 1000 21 Jan 28 16:00 .gitkeep
  131. -r--r--r-- 1 root root 1281 Jan 28 16:07 mqtt_ca.crt
  132. /etc/mosquitto/certs/
  133. total 12
  134. -rw-r--r-- 1 1000 1000 21 Jan 28 16:00 .gitkeep
  135. -r--r--r-- 1 root root 1891 Jan 28 16:07 mqtt_srv.crt
  136. -r-------- 1 root root 1679 Jan 28 16:07 mqtt_srv.key
  137. /etc/mosquitto/password.txt
  138. admin:$6$uXNbKcSuDpNZYcmHivYC1fg3neSmmsdLxlI5A==
  139.  
  140. $ ls -A SmartHome/docker/mosquitto/volume/.ca
  141. .gitkeep mqtt_ca.key mqtt_srv.crt mqtt_srv.key
  142. mqtt_ca.crt mqtt_ca.srl mqtt_srv.csr
  143.  
  144. $ docker commit mosquitto debug
  145. $ docker run --rm -it debug /bin/bash
  146.  
  147. $ pwd
  148. /etc/mosquitto/.ca
  149. $ ls -A
  150. .gitkeep
  151.  
  152. $ /init
  153. WARNING: Your kernel does not support memory swappiness capabilities, memory swappiness discarded.
  154. root@aba7a43aaeab:/etc/mosquitto/.ca# /init
  155. /etc/mosquitto/.ca
  156. Generating a RSA private key
  157. ..............................................................................+++++
  158. .................................................................................................................+++++
  159. writing new private key to './ca.key'
  160. -----
  161. Created CA certificate in ./ca.crt
  162. subject=
  163. commonName = MQTT Broker example.com
  164. organizationName = example.com
  165. emailAddress = me@example.com
  166. Warning: the CA key is not encrypted; store it safely!
  167. --- Creating server key and signing request
  168. Generating RSA private key, 2048 bit long modulus
  169. .................+++++
  170. ......+++++
  171. e is 65537 (0x010001)
  172. --- Creating and signing server certificate
  173. Signature ok
  174. subject=CN = pi.example.us, O = example.com, emailAddress = me@example.com
  175. Getting CA Private Key
  176. total 28
  177. -rw-r--r-- 9 root root 21 Jan 28 16:00 .gitkeep
  178. -r--r--r-- 1 root root 1281 Jan 28 16:40 mqtt_ca.crt
  179. -r-------- 1 root root 1708 Jan 28 16:40 mqtt_ca.key
  180. -rw-r--r-- 1 root root 17 Jan 28 16:40 mqtt_ca.srl
  181. -r--r--r-- 1 root root 1883 Jan 28 16:40 mqtt_srv.crt
  182. -rw-r--r-- 1 root root 968 Jan 28 16:40 mqtt_srv.csr
  183. -r-------- 1 root root 1675 Jan 28 16:40 mqtt_srv.key
  184. /etc/mosquitto/
  185. total 60
  186. drwxr-xr-x 1 root root 4096 Jan 28 16:40 .ca
  187. drwxr-xr-x 1 root root 4096 Jan 28 16:40 ca_certificates
  188. drwxr-xr-x 1 root root 4096 Jan 28 16:40 certs
  189. drwxr-xr-x 2 root root 4096 Jan 28 16:10 conf.d
  190. -rw-r--r-- 9 root root 750 Jan 28 16:00 mosquitto.conf
  191. -rw-r--r-- 9 root root 33112 Jan 28 16:00 mosquitto.conf.example
  192. -rw-r--r-- 9 root root 115 Jan 28 16:00 password.txt
  193. /etc/mosquitto/ca_certificates/
  194. total 8
  195. -rw-r--r-- 9 root root 21 Jan 28 16:00 .gitkeep
  196. -r--r--r-- 1 root root 1281 Jan 28 16:40 mqtt_ca.crt
  197. /etc/mosquitto/certs/
  198. total 12
  199. -rw-r--r-- 9 root root 21 Jan 28 16:00 .gitkeep
  200. -r--r--r-- 1 root root 1883 Jan 28 16:40 mqtt_srv.crt
  201. -r-------- 1 root root 1675 Jan 28 16:40 mqtt_srv.key
  202. /etc/mosquitto/password.txt
  203. admin:$6$uXNKcSuDpNZYWO9I$6FmqWeO==
  204.  
  205. $ docker ps
  206. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  207. aba7a43aaeab debug "/bin/bash" 13 minutes ago Up 13 minutes 8883/tcp, 9001/tcp tender_poincare
Add Comment
Please, Sign In to add comment