docker-compose configs
时间: 2023-09-27 07:03:53 浏览: 88
docker-compose
Docker Compose configs are used to define and configure multi-container Docker applications. With Docker Compose, you can specify the services, networks, volumes, and other configurations required for your application in a single YAML file called `docker-compose.yml`.
In the `docker-compose.yml` file, you can define multiple services, each representing a container in your application. Each service can have its own configuration, such as the image to use, environment variables, ports to expose, volumes to mount, etc.
Here's an example of a simple `docker-compose.yml` file:
```yaml
version: '3'
services:
web:
image: nginx:latest
ports:
- 80:80
volumes:
- ./html:/usr/share/nginx/html
db:
image: mysql:latest
environment:
- MYSQL_ROOT_PASSWORD=secret
- MYSQL_DATABASE=mydb
- MYSQL_USER=myuser
- MYSQL_PASSWORD=mypassword
```
In this example, two services are defined: `web` and `db`. The `web` service uses the `nginx` image, exposes port 80 on the host, and mounts a local directory `./html` to the container's `/usr/share/nginx/html` directory. The `db` service uses the `mysql` image and sets some environment variables for configuration.
You can use the `docker-compose` command-line tool to manage and interact with your Docker Compose application. For example, you can start the application using `docker-compose up`, stop it using `docker-compose down`, or view logs using `docker-compose logs`.
I hope this helps! Let me know if you have any more questions.
阅读全文