Docker - docker-compose (2)
Docker - docker-compose (2)
Docker - docker-compose (2)
Amine FERDJAOUI
[email protected]
Docker
fi
fi
fi
Docker-compose file
• Uses yml (or yaml) le, usually used for con guration, it uses indentation (like python)
Docker
fi
fi
fi
fi
Installation
• If you are under mac or windows, docker-compose comes installed with Docker desktop
• For Linux : follow installation instructions on : https://docs.docker.com/compose/install/
$ docker-compose --version
Docker
Docker-compose file https://docs.docker.com/reference/compose- le/
Docker
fi
Docker-compose file https://github.com/AmineFrj/docker-compose
docker-compose.yml
1 version: “3.8”
2 services:
3 backend:
4 build: .
5 ports:
6 - ”5000:5000”
7 volumes:
8 - ./templates:/templates #<local>:<container>
9 volumes:
10 templates: #pour sauvegarder le volume même après la suppression
Docker
Docker-compose commands - build
All commands are the same as docker commands except that the docker-compose ones
will be applied to the hole applications.
Build
Enter into the docker-compose le directory and run build command (without
any ags)
Image will be named: <folder-name> _ <service-name>
Docker
fl
fi
Docker-compose commands - Start
Run
Once the image built, the run command starts the new container(s)
$ docker compose up
If the image is not built, you can build the image and then run it
Docker
Docker-compose commands - Stop and remove
Stop
To stop and remove containers (images are not removed)
Docker
Docker-compose - commands recap
Build docker image
Run container
Docker