$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 745159676ccd docker-test "java -jar spring5we…" 30 seconds ago Up 28 seconds stoic_mendeleev
$ docker logs 745159676ccd 2023-02-18 09:19:38.674 INFO 1 --- [ main] g.s.s.Spring5webappApplication : Starting Spring5webappApplication v0.0.1-SNAPSHOT on 47d036941a06 with PID 1 (/application/spring5webapp-0.0.1-SNAPSHOT.jar started by root in /application) 2023-02-18 09:19:38.681 INFO 1 --- [ main] g.s.s.Spring5webappApplication : No active profile set, falling back to default profiles: default ...
$ docker login
$ docker tag docker-test lunski/docker-test:latest
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 939e5b6d5069 springframeworkguru/kbe-brewery-gateway "java -Djava.securit…" 7 minutes ago Up 5 minutes 8080/tcp, 0.0.0.0:9090->9090/tcp kbe-sb-microservices-gateway-1 8e83a8ebfcce springframeworkguru/kbe-brewery-order-service "java -Djava.securit…" 7 minutes ago Up 5 minutes 8080/tcp, 0.0.0.0:8081->8081/tcp kbe-sb-microservices-order-service-1 397a3aa28db5 springframeworkguru/kbe-brewery-beer-service "java -Djava.securit…" 7 minutes ago Up 5 minutes 0.0.0.0:8080->8080/tcp kbe-sb-microservices-beer-service-1 c0fd84ac07cc springframeworkguru/kbe-brewery-inventory-service "java -Djava.securit…" 7 minutes ago Up 5 minutes 8080/tcp, 0.0.0.0:8082->8082/tcp kbe-sb-microservices-inventory-service-1 fe888556718e docker.elastic.co/kibana/kibana:7.12.1 "/bin/tini -- /usr/l…" 7 minutes ago Up 5 minutes 0.0.0.0:5601->5601/tcp kbe-sb-microservices-kibana-1 63c580abe7df docker.elastic.co/beats/filebeat:7.12.1 "/usr/bin/tini -- /u…" 7 minutes ago Up 6 minutes kbe-sb-microservices-filebeat-1 114892532cef docker.elastic.co/elasticsearch/elasticsearch:7.12.1 "/bin/tini -- /usr/l…" 7 minutes ago Up 6 minutes 0.0.0.0:9200->9200/tcp, 9300/tcp kbe-sb-microservices-elasticsearch-1 8c82873f197f mysql:5.7 "docker-entrypoint.s…" 7 minutes ago Up 6 minutes 3306/tcp, 33060/tcp kbe-sb-microservices-mysql-1 30b5d87f882f springframeworkguru/kbe-brewery-inventory-failover "java -Djava.securit…" 7 minutes ago Up 6 minutes 8080/tcp, 0.0.0.0:8083->8083/tcp kbe-sb-microservices-inventory-failover-1 4710a51dcdd9 vromero/activemq-artemis "/docker-entrypoint.…" 7 minutes ago Up 6 minutes 1883/tcp, 5445/tcp, 5672/tcp, 9404/tcp, 0.0.0.0:8161->8161/tcp, 61613/tcp, 0.0.0.0:61616->61616/tcp kbe-sb-microservices-jms-1
# 終止 $ docker compose -f compose-local.yaml down [+] Running 8/9 ⠿ Container kbe-sb-microservices-filebeat-1 Removed 57.2s ⠿ Container kbe-sb-microservices-kibana-1 Removed 63.7s ⠿ Container kbe-sb-microservices-mysql-1 Removed 57.2s ⠿ Container kbe-sb-microservices-gateway-1 Removed 57.8s ⠿ Container kbe-sb-microservices-inventory-failover-1 Removed 24.4s ⠿ Container kbe-sb-microservices-order-service-1 Removed 25.2s ⠿ Container kbe-sb-microservices-elasticsearch-1 Removed 19.6s ⠿ Container kbe-sb-microservices-beer-service-1 Removed 20.7s ⠿ Container kbe-sb-microservices-inventory-service-1 Error while Sto... 22.8s Error response from daemon: cannot stop container: c0fd84ac07ccc32040510f0bfb6ecb25a6f36cc75674d76f55015211dc3bf3a4: container c0fd84ac07cc PID 37030 is zombie and can not be killed. Use the --init option when creating containers to run an init inside the container that forwards signals and reaps processes
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4710a51dcdd9 vromero/activemq-artemis "/docker-entrypoint.…" 35 minutes ago Up 34 minutes 1883/tcp, 5445/tcp, 5672/tcp, 9404/tcp, 0.0.0.0:8161->8161/tcp, 61613/tcp, 0.0.0.0:61616->61616/tcp kbe-sb-microservices-jms-1
$ docker stop 4710a51dcdd9 4710a51dcdd9
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Command
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
docker-compose 常用指令 (一次全部 services 一起執行)
docker-compose up docker-compose up -d (在背後執行) docker-compose up --build (Dockerfile 重新 build) docker-compose down docker-compose down -v (連 volume 一起刪除) docker-compose ps (看目前所有 services 狀態)
Architecture: Docker requires a daemon process that runs with root privileges. Podman does not require a daemon and the podman commands are run as a regular user. This removes the need for root privileges that Docker requires.
Image registry: Docker uses a centralized image registry/repository by default. Podman can use any OCI compliant registry, including Docker’s registry as well as decentralized registries.
Container engine: Docker uses its own APIs and CLI. Podman is compliant with OCI (Open Container Initiative) specs and can use any OCI compliant container engine. This makes it more compatible with Kubernetes.
Rootless containers: Podman can run rootless containers without requiring root access. This improves security. Docker now allows rootless containers as well, but the setup is more complex compared to Podman.
Networking: Docker has its own networking stack. Podman uses CNI plugins for networking. This makes it easier for Podman to leverage Kubernetes networking.
Storage drivers: Docker has its own storage driver architecture. Podman builds on top of existing solutions like device mapper, overlayfs, VFS, etc. This allows more flexibility in leveraging existing tools.
Podman is more secure, compatible and flexible. Docker is more popular and widely-used in production.
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b2006f0bcc16 lunski/docker-test "java -jar spring5we…" 2 minutes ago Up 2 minutes k8s_docker-test_kbe-test-66bc4c5859-ctcq6_default_44e1d282-ea5b-4809-89d0-9995139b80ba_0
Port Forwarding
forward local ip 192.168.0.139 to cluster-ip 10.97.167.213
1 2 3 4 5 6
$ ipconfig getifaddr en0 192.168.0.139
$ kubectl port-forward service/kbe-test 8080:8080 Forwarding from 127.0.0.1:8080 -> 8080 Forwarding from [::1]:8080 -> 8080
Delete
1 2 3 4 5
$ kubectl delete service kbe-test service "kbe-test" deleted
$ kubectl apply -f jms-service.yml service/jms created
$ kubectl get all kubectl get all NAME READY STATUS RESTARTS AGE pod/jms-5cd9686f76-vjrl2 1/1 Running 0 7m37s pod/mysql-74bd96b965-6qs4w 0/1 CrashLoopBackOff 9 (3m18s ago) 24m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/jms ClusterIP 10.102.217.165 <none> 8161/TCP,6161/TCP 47s service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 16d service/mysql ClusterIP 10.100.88.211 <none> 3306/TCP 17m
NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/jms 1/1 1 1 7m37s deployment.apps/mysql 0/1 1 0 24m
NAME DESIRED CURRENT READY AGE replicaset.apps/jms-5cd9686f76 1 1 1 7m37s replicaset.apps/mysql-74bd96b965 1 1 0 24m
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6999802c8c0b vromero/activemq-artemis "/docker-entrypoint.…" 8 minutes ago Up 8 minutes k8s_activemq-artemis_jms-5cd9686f76-vjrl2_default_ba1c34e2-ff52-41f4-bc63-35022965b6fa_0