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