Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FROM schachr/raspbian-stretch:latest
- docker run -d --net=host
- -e "FQDN=mqtt.example.com"
- -e "EMAIL=me@example.com"
- -e "DOMAIN=example.com"
- -e "IPLIST=172.16.16.16 192.168.1.254"
- -e "HOSTLIST=somehost.example.com docker.example.com"
- -v /home/admin/mosquitto/conf.d:/etc/mosquitto/conf.d:z
- -t mosibi/mosquitto
- System error: exec format error
- FROM schachr/raspbian-stretch:latest
- MAINTAINER admin <admind@example.com>
- ENV LC_ALL="C"
- LANG="en_US.UTF-8"
- TZ="Asia/Tokyo"
- WORKDIR /tmp
- # Configure no init scripts to run on package updates.
- ADD files/policy-rc.d /usr/sbin/policy-rc.d
- RUN chmod 755 /usr/sbin/policy-rc.d &&
- : dash を bash に変更 &&
- ln -f /bin/bash /bin/sh &&
- apt update &&
- apt install -y rename openssl
- mosquitto mosquitto-clients &&
- : mosquitto フォルダを空にする &&
- rm -rf /etc/mosquitto &&
- mkdir /etc/mosquitto
- # COPY files
- COPY volume /etc/mosquitto/
- COPY files/generate-CA.sh /usr/local/bin/generate-CA.sh
- COPY files/init /init
- RUN chmod 755 /usr/local/bin/generate-CA.sh &&
- chmod 755 /init
- # generate-CA.sh 実行時のディレクトリ
- WORKDIR /etc/mosquitto/.ca
- # MQTT ports
- #EXPOSE 1883
- EXPOSE 8883
- EXPOSE 9001
- CMD [ "/init" ]
- $HOME/SmartHome/
- ├─ README.md
- └─ docker
- └── mosquitto
- ├── Dockerfile
- ├── files
- │ ├── generate-CA.sh
- │ ├── init
- │ └── policy-rc.d
- └── volume
- ├── ca_certificates
- │ └── mqtt_ca.crt
- ├── certs
- │ ├── mqtt_srv.crt
- │ └── mqtt_srv.key
- ├── conf.d
- │ ├── mosquitto.conf
- │ └── websockets.conf
- ├── mosquitto.conf
- ├── mosquitto.conf.example
- └── password.txt
- $ cd SmartHome/docker/mosquitto
- $ docker build -t admin/mosquitto .
- $ docker run -it -d --name mosquitto --net=host
- -e "FQDN=pi.example.us"
- -e "EMAIL=me@example.com"
- -e "DOMAIN=example.com"
- -e "IPLIST=192.168.0.220 172.20.10.220"
- -e "HOSTLIST=pi pi.local pi.example.us 192.168.0.220 172.20.10.220"
- -v /home/admin/SmartHome/docker/mosquitto/volume:/etc/mosquitto
- -t admin/mosquitto
- $ docker ps -a
- ・・・ Exited (1) 10 seconds ago
- $ docker logs mosquitto
- /etc/mosquitto/.ca
- Generating a RSA private key
- ...............+++++
- ................................................+++++
- writing new private key to './ca.key'
- -----
- Created CA certificate in ./ca.crt
- subject=
- commonName = MQTT Broker example.com
- organizationName = example.com
- emailAddress = me@example.com
- Warning: the CA key is not encrypted; store it safely!
- --- Creating server key and signing request
- Generating RSA private key, 2048 bit long modulus
- ..+++++
- .....................................................................+++++
- e is 65537 (0x010001)
- --- Creating and signing server certificate
- Signature ok
- subject=CN = pi.example.us, O = example.com, emailAddress = me@example.com
- Getting CA Private Key
- total 28
- -rw-r--r-- 1 1000 1000 21 Jan 28 16:00 .gitkeep
- -r--r--r-- 1 root root 1281 Jan 28 16:07 mqtt_ca.crt
- -r-------- 1 root root 1704 Jan 28 16:07 mqtt_ca.key
- -rw-r--r-- 1 root root 17 Jan 28 16:07 mqtt_ca.srl
- -r--r--r-- 1 root root 1891 Jan 28 16:07 mqtt_srv.crt
- -rw-r--r-- 1 root root 968 Jan 28 16:07 mqtt_srv.csr
- -r-------- 1 root root 1679 Jan 28 16:07 mqtt_srv.key
- /etc/mosquitto/
- total 60
- drwxr-xr-x 2 1000 1000 4096 Jan 28 16:07 .ca
- drwxr-xr-x 2 1000 1000 4096 Jan 28 16:07 ca_certificates
- drwxr-xr-x 2 1000 1000 4096 Jan 28 16:07 certs
- drwxr-xr-x 2 1000 1000 4096 Jan 28 16:00 conf.d
- -rw-r--r-- 1 1000 1000 750 Jan 28 16:00 mosquitto.conf
- -rw-r--r-- 1 1000 1000 33112 Jan 28 16:00 mosquitto.conf.example
- -rw-r--r-- 1 1000 1000 115 Jan 28 16:00 password.txt
- /etc/mosquitto/ca_certificates/
- total 8
- -rw-r--r-- 1 1000 1000 21 Jan 28 16:00 .gitkeep
- -r--r--r-- 1 root root 1281 Jan 28 16:07 mqtt_ca.crt
- /etc/mosquitto/certs/
- total 12
- -rw-r--r-- 1 1000 1000 21 Jan 28 16:00 .gitkeep
- -r--r--r-- 1 root root 1891 Jan 28 16:07 mqtt_srv.crt
- -r-------- 1 root root 1679 Jan 28 16:07 mqtt_srv.key
- /etc/mosquitto/password.txt
- admin:$6$uXNbKcSuDpNZYcmHivYC1fg3neSmmsdLxlI5A==
- $ ls -A SmartHome/docker/mosquitto/volume/.ca
- .gitkeep mqtt_ca.key mqtt_srv.crt mqtt_srv.key
- mqtt_ca.crt mqtt_ca.srl mqtt_srv.csr
- $ docker commit mosquitto debug
- $ docker run --rm -it debug /bin/bash
- $ pwd
- /etc/mosquitto/.ca
- $ ls -A
- .gitkeep
- $ /init
- WARNING: Your kernel does not support memory swappiness capabilities, memory swappiness discarded.
- root@aba7a43aaeab:/etc/mosquitto/.ca# /init
- /etc/mosquitto/.ca
- Generating a RSA private key
- ..............................................................................+++++
- .................................................................................................................+++++
- writing new private key to './ca.key'
- -----
- Created CA certificate in ./ca.crt
- subject=
- commonName = MQTT Broker example.com
- organizationName = example.com
- emailAddress = me@example.com
- Warning: the CA key is not encrypted; store it safely!
- --- Creating server key and signing request
- Generating RSA private key, 2048 bit long modulus
- .................+++++
- ......+++++
- e is 65537 (0x010001)
- --- Creating and signing server certificate
- Signature ok
- subject=CN = pi.example.us, O = example.com, emailAddress = me@example.com
- Getting CA Private Key
- total 28
- -rw-r--r-- 9 root root 21 Jan 28 16:00 .gitkeep
- -r--r--r-- 1 root root 1281 Jan 28 16:40 mqtt_ca.crt
- -r-------- 1 root root 1708 Jan 28 16:40 mqtt_ca.key
- -rw-r--r-- 1 root root 17 Jan 28 16:40 mqtt_ca.srl
- -r--r--r-- 1 root root 1883 Jan 28 16:40 mqtt_srv.crt
- -rw-r--r-- 1 root root 968 Jan 28 16:40 mqtt_srv.csr
- -r-------- 1 root root 1675 Jan 28 16:40 mqtt_srv.key
- /etc/mosquitto/
- total 60
- drwxr-xr-x 1 root root 4096 Jan 28 16:40 .ca
- drwxr-xr-x 1 root root 4096 Jan 28 16:40 ca_certificates
- drwxr-xr-x 1 root root 4096 Jan 28 16:40 certs
- drwxr-xr-x 2 root root 4096 Jan 28 16:10 conf.d
- -rw-r--r-- 9 root root 750 Jan 28 16:00 mosquitto.conf
- -rw-r--r-- 9 root root 33112 Jan 28 16:00 mosquitto.conf.example
- -rw-r--r-- 9 root root 115 Jan 28 16:00 password.txt
- /etc/mosquitto/ca_certificates/
- total 8
- -rw-r--r-- 9 root root 21 Jan 28 16:00 .gitkeep
- -r--r--r-- 1 root root 1281 Jan 28 16:40 mqtt_ca.crt
- /etc/mosquitto/certs/
- total 12
- -rw-r--r-- 9 root root 21 Jan 28 16:00 .gitkeep
- -r--r--r-- 1 root root 1883 Jan 28 16:40 mqtt_srv.crt
- -r-------- 1 root root 1675 Jan 28 16:40 mqtt_srv.key
- /etc/mosquitto/password.txt
- admin:$6$uXNKcSuDpNZYWO9I$6FmqWeO==
- ▮
- $ docker ps
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- aba7a43aaeab debug "/bin/bash" 13 minutes ago Up 13 minutes 8883/tcp, 9001/tcp tender_poincare
Add Comment
Please, Sign In to add comment