dockerでIOT-Houseをする まとめ
MACでIOTハウス(Input Output Things)構築に三ヶ月程Dockerにハマってしまい
結局、Lubuntu:20.04をWindows10 Homeマシンの外付けDISKへインストール
1週間程でIOT-House_dockerをリリース出来たけど
備忘として簡単なdocker コマンドを列挙しておこう
## docker simple command list
# cat Dockerfile
.
FROM amd64/ubuntu:20.04
#FROM i386/ubuntu:18.04
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=Asia/Tokyo
.
# Copy Dockerfile
COPY Dockerfile /Dockerfile
RUN apt-get update && apt-get install -y \
tzdata \
rsyslog \
.
COPY app-src/lubuntu_cmd.tar.gz /usr/src/pepolinux/
ADD app-src/lubuntu_cmd.tar.gz /usr/local/bin/
.
EXPOSE 22 80 443
#ENTRYPOINT ["/etc/rc.local_docker"] <-- Be sure to execute
CMD ["/etc/rc.local_docker"] <-- Run by default
# docker build ./ -t iot-house_docker:v0.01 <-- Build
# docker run -itd --privileged --name iot-house_docker --device=/dev/ttyUSB0:/dev/ttyUSBTWE-Lite -p 8022:22 -p 80:80 -p 443:443 kujiranodanna/iot-house_docker:v0.01 /etc/rc.local <-- Run
# docker images <-- List images
REPOSITORY TAG IMAGE ID CREATED SIZE
kujiranodanna/iot-house_docker ubuntu20.04 5fc30d6b4480 24 hours ago 738MB
kujiranodanna/iot-house_docker ubuntu18.04 d9a581c1e78a 24 hours ago 579MB
amd64/ubuntu 20.04 ba6acccedd29 6 weeks ago 72.8MB
i386/ubuntu 18.04 b44056bbf2d5 8 weeks ago 64MB
hello-world latest feb5d9fea6a5 2 months ago 13.3kB
# docker system df <-- Cache confirmation
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 5 2 1.317GB 136.7MB (10%)
Containers 2 0 50.72kB 50.72kB (100%)
Local Volumes 4 0 0B 0B
Build Cache 0 0 0B 0B
docker builder prune <-- Build Cache clean
# docker ps -a <-- List container
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8da1c3305da0 d9a581c1e78a "/etc/rc.local_docker" 23 hours ago Exited (137) 23 hours ago iot-house_docker386
3b0894ec1482 5fc30d6b4480 "/etc/rc.local_docker" 23 hours ago Exited (137) 22 hours ago iot-house_docker64
# docker start iot-house_docker386
iot-house_docker386
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8da1c3305da0 d9a581c1e78a "/etc/rc.local_docker" 23 hours ago Up 30 seconds 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:8022->22/tcp, :::8022->22/tcp iot-house_docker386
3b0894ec1482 5fc30d6b4480 "/etc/rc.local_docker" 23 hours ago Exited (137) 23 hours ago iot-house_docker64
# docker exec -it iot-house_docker386 bash <-- Into container
root@8da1c3305da0:/# ps ax
PID TTY STAT TIME COMMAND
1 pts/0 Ss 0:00 /bin/sh -e /etc/rc.local_docker
46 ? S 0:00 /usr/bin/svscan /service
48 ? S 0:00 supervise gmail4diod
root@8da1c3305da0:/# exit
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8da1c3305da0 d9a581c1e78a "/etc/rc.local_docker" 23 hours ago Up 5 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:8022->22/tcp, :::8022->22/tcp iot-house_docker386
3b0894ec1482 5fc30d6b4480 "/etc/rc.local_docker" 23 hours ago Exited (137) 23 hours ago
# docker commit iot-house_docker386 iot-house_docker:latest <-- Copy container to image
sha256:78939cadd42b4a1cbd89eae284dd1a3fc8d7fc3cba40e9117ca67550b1e15c43
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
iot-house_docker latest 78939cadd42b 49 seconds ago 579MB
kujiranodanna/iot-house_docker ubuntu20.04 5fc30d6b4480 24 hours ago 738MB
kujiranodanna/iot-house_docker ubuntu18.04 d9a581c1e78a 25 hours ago 579MB
# docker rmi iot-house_docker:latest <-- image delete(REPOSITORY:TAG)
Untagged: iot-house_docker:latest
Deleted: sha256:78939cadd42b4a1cbd89eae284dd1a3fc8d7fc3cba40e9117ca67550b1e15c43
Deleted: sha256:1595757945c830c9ece79a465e3fd8671209b1b6dd804b3729d10f4390aeb390
root@dell:/opt/Docker# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
kujiranodanna/iot-house_docker ubuntu20.04 5fc30d6b4480 25 hours ago 738MB
kujiranodanna/iot-house_docker ubuntu18.04 d9a581c1e78a 25 hours ago 579MB
amd64/ubuntu 20.04 ba6acccedd29 6 weeks ago 72.8MB
# docker stop iot-house_docker386 <-- Container stop
iot-house_docker386
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8da1c3305da0 d9a581c1e78a "/etc/rc.local_docker" 24 hours ago Exited (137) About a minute ago iot-house_docker386
3b0894ec1482 5fc30d6b4480 "/etc/rc.local_docker" 24 hours ago Exited (137) 23 hours ago iot-house_docker64
# docker rm iot-house_docker386 <-- Container delete
iot-house_docker386
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3b0894ec1482 5fc30d6b4480 "/etc/rc.local_docker" 24 hours ago Exited (137) 23 hours ago iot-house_docker64
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 2 months ago 13.3kB
root@dell:/opt/Docker# docker tag hello-world:latest hello-world:v0.01 <-- image tag copy
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 2 months ago 13.3kB
hello-world v0.01 feb5d9fea6a5 2 months ago 13.3kB
# docker rmi hello-world:v0.01 <-- image delete(REPOSITORY:TAG)
Untagged: hello-world:v0.01