2018 -
08 / 16

2018 / 08 / 16

手把手帶你學 Docker - Docker Compose


何適宇 Matt Ho

SoftLeader R&D  |     Github


Define services in a Compose file


Create a file called docker-compose.yml and paste the following :

version: '3'
services:
  mytomcat:
   image: mytomcat
   ports:
   - "8081:8080"
   volumes:
   - .:/logs

資料來源 : https://docs.docker.com/compose/gettingstarted/



Start services with Compose


# Create and start all containers in the background
docker-compose up -d

# Connect to tomcat inside the container
curl localhost:8081



常用指令


# Create and start all containers in the background
docker-compose up -d

# Stop all running containers
docker-compose stop

# Stop and remove all containers, networks, images, and volumes
docker-compose down

# Follow logs for all containers
docker-compose logs --follow



實作看看


index.html mount 出來的版本也改成 compose 吧!

Congratulations!


你已經學會了基本款的 docker 應用了, 期待之後的 Kubernetes Tutorials 吧!