安装docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.28.6/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker‐compose
docker-compose --version
目录树结构如下:
├── docker-compose.yml └── demo ├──── Dockerfile └──── demo.jar
Dockerfile内容
From java:8
ADD demo.jar /demo.jar
EXPOSE 8888
ENTRYPOINT java ${JAVA_OPTS} -jar /demo.jar
docker-compose.yml的内容如下
version: '1.0.0'
services:
demo:
image: demo:1.0.0
build: ./demo
ports:
- "8888:8888"
expose:
- 8888
volumes:
- ./demo/:/etc/demo/
启动
docker-compose up -d
注:如果docker-compose.yml不是这个名称,需要指定文件名,如果是则可以不用指定。
docker-compose -f docker-compose-demo.yml up -d
访问
http://myHost:8888
|