要启动在docker-compose文件中定义的特定服务。例如,如果您有docker-compose.yml
sudo docker-compose start db
给定一个撰写文件,如下所示:
version: '3.3'
services:
db:
image: mysql:5.7
ports:
- "3306:3306"
volumes:
- ./db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: yourPassword
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: yourPassword
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "80:80"
volumes:
- ./l3html:/var/www/html
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: yourPassword
volumes:
db_data:
l3html:
有时,您只想启动mySQL(有时只想填充数据库),然后再启动整个套件。
docker-compose up [options] [SERVICE...]
您可以启动要列出的任何服务子集。