sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
docker-compose -v
mvn clean package
FROM java:8 VOLUME /tmp ADD docker-demo-0.0.1-SNAPSHOT.jar app.jar RUN bash -c 'touch /app.jar' EXPOSE 9000 ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","app.jar"]
version: '2' # 表示該 Docker-Compose 文件使用的是 Version 2 file services: docker-demo: # 指定服務名稱 build: . # 指定 Dockerfile 所在路徑 ports: # 指定端口映射 - "9000:8761"
docker-compose up docker-compose up -d // 後臺啓動並運行容器
docker-compose ps
docker-compose logs
docker-compose port eureka 8761
docker-compose build
docker-compose start eureka
docker-compose stop eureka
docker-compose rm eureka
docker-compose up
docker-compose kill eureka
docker-compose scale user=3 movie=3
docker-compose run web bash
build: ./dir --------------- build: context: ./dir dockerfile: Dockerfile args: buildno: 1
command: bundle exec thin -p 3000 ---------------------------------- command: [bundle,exec,thin,-p,3000]
dns: 8.8.8.8 ------------ dns: - 8.8.8.8 - 9.9.9.9
dns_search: example.com ------------------------ dns_search: - dc1.example.com - dc2.example.com
environment:
RACK_ENV: development
SHOW: 'ture' ------------------------- environment: - RACK_ENV=development - SHOW=ture
env_file: .env --------------- env_file: - ./common.env
expose:
- "3000" - "8000"
image: java
network_mode: "bridge" network_mode: "host" network_mode: "none" network_mode: "service:[service name]" network_mode: "container:[container name/id]"
ports: # 暴露端口信息 - "宿主機端口:容器暴露端口" - "8763:8763" - "8763:8763"
links: # 指定服務名稱:別名 - docker-compose-eureka-server:compose-eureka
volumes:
- /lib
- /var
--no-color 單色輸出,不顯示其餘顏. -f, --follow 跟蹤日誌輸出,就是能夠實時查看日誌 -t, --timestamps 顯示時間戳 --tail 從日誌的結尾顯示,--tail=200
version: '2' services: web: build: . links: - "db:database" db: image: postgres
連接:https://www.jianshu.com/p/658911a8cff3
php