你真的會用Arrays.asList 和 Arraylist.subList嗎?避免入坑!!
阿新 • • 發佈:2021-06-22
docker-compose是容器編排工具,需要注意的是,docker-compose只是單機的容器編排工具
docker-compose 預設的配置檔案為 : docker-compose.yaml
1 安裝docker-compose
# 下載 docker文件 : `https://docs.docker.com/compose/install/` 1 sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose2 sudo chmod +x /usr/local/bin/docker-compose 3 sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose 4 docker-compose --version
2 docker-compose模板檔案
version: "3.0" services: django: image: django:v2 ports: - "8080:8080" container_name: django networks: - django depends_on:- mysql mysql: image: mysql:5.7 environment: MYSQL_ROOT_PASSWORD: admin123 MYSQL_DATABASE: bbs09 container_name: mysql volumes: - "/root/docker-compose/mysql/data:/var/lib/mysql" networks: - django depends_on: - redis redis: image: redis:latest container_name: redis networks:- django networks: django:
3 docker-compose指令
# build version: "3.0" services: django: build: ./django --- version: "3.0" services: django: build: context: ./django dockerfile: Dockerfile args: NAME: python # command : 設定容器啟動命令 # depends_on : 指定在某容器之後啟動(依賴於某容器) # env_file : 指定環境變數檔案
4 docker-compose引數
`啟動` : docker-compose up `停止並刪除` : docker-compose down `停止` : docker-compose stop `刪除容器` : docker-compose rm `重啟` : docker-compose restart 容器名稱 `進入容器` : docker-compose exec 引數 service CMD `容器列表` : docker-compose ps `檢視容器程序` : docker-compose top `暫停執行` : docker-compose pause `恢復執行` : docker-compose unpause
5 視覺化工具
version: '3.0' services: portainer: image: portainer/portainer-ce ports: - "8001:8000" - "9001:9000" container_name: portainer networks: - "portainer" volumes: - "/var/run/docker.sock:/var/run/docker.sock" - "/root/docker-compose/portainer_data:/data" healthcheck: test: ["CMD", "ping", "-c1", "-t1", "portainer"] interval: 30s timeout: 10s retries: 3 networks: portainer: