---
# System prepended metadata

title: Docker筆記

---

# Docker筆記

## Docker Concept
![](https://i.imgur.com/Q9f2ji8.png)

## Pod Concept
https://ikala.cloud/gke-k8s-pod-network/
![](https://hackmd.io/_uploads/S1qk5Cdj3.png)


## 相關線上資源：
* Dockerhub：https://hub.docker.com/
* Oracle DB：docker pull store/oracle/database-enterprise:12.2.0.1
* Java：docker pull openjdk:8-alpine
* Tomcat：docker pull tomcat

## 相關指令：
* 打包Image：docker build -t allianz-sd .
-t：Image Tag名稱
參數1：哪個目錄要打包到Image(.代表當下目錄)
* 載入Image開Container：
docker run -p 8080:8080 --name ap1 allianz-sd-app
* 讓Container與local網段相同：
docker run --expose=8080 --network="host" allianz-sd-app
* 列出所有Container：
docker ps -a
* 刪除Container：
docker rm -f {container-id}
* 刪除Image：
docker rmi {imageID}

## Mac安裝docker
brew install --cask docker

## 將docker上傳至GCP

參考文件：https://medium.com/k8s%E7%AD%86%E8%A8%98/kubernetes-%E9%83%A8%E7%BD%B2spring-boot-%E6%87%89%E7%94%A8%E7%A8%8B%E5%BC%8F%E5%88%B0-kubernetes-deploy-spring-boot-on-kubernetes-gke-cdb87cf81038

安裝kubecli：https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/

## 將docker上傳至Google registry
https://cloud.google.com/artifact-registry/docs/docker/pushing-and-pulling

## 安裝python
https://pythonviz.com/basic/install-python3-macos-homebrew/

## 異常處理：
* 如果打包出現網路異常，切換到windows docker mode後，執行下列項目：
1.到Setting
2.到Daemon，切換到Advanced，把"experimental": true

## Install MSSQL Docker:
https://dotblogs.com.tw/rexhuang/2020/03/07/223552


ddocker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=1q@W3e$R5t" -p 1433:1433 -v D:\mssql-data  --name mssql -d mcr.microsoft.com/mssql/server

## docker create volumes
https://larrylu.blog/using-volumn-to-persist-data-in-container-a3640cc92ce4

## install mssql docker for mac:
https://builtin.com/software-engineering-perspectives/sql-server-management-studio-mac

## docker install apache

docker pull httpd

sudo docker run -itd --name apache_web -p 8085:80 -v /Users/neux/IdeaProjects/cms-api/apache/:/usr/local/apache2/htdocs/ docker.io/httpd:latest


## MySQL Docker：
https://berglas.github.io/dest/articles/2020/12/learn_docker_2.html

CREATE USER 'test'  IDENTIFIED BY 'test123';
GRANT ALL ON *.* TO 'test'  WITH GRANT OPTION;
ALTER USER 'test' IDENTIFIED WITH mysql_native_password BY 'test123';

## Apache Docker：
https://zhuanlan.zhihu.com/p/106587011

## Docker CLI指令：
https://www.runoob.com/docker/docker-command-manual.html