标签:running code single png mys www 简单 file you
以下定义摘自docker官网:https://docs.docker.com/compose/overview/
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
Compose是一个用来定义、运行多容器Docker应用的工具。通过compose,你使用YAML文件来定义你的应用服务。然后,通过一个简单的命令,就能创建和启动你配置的所有服务。
从定义可以看出,Compose是一个工具,用来定义多个容器服务,然后通过一个命令一键启停所有服务,方便管理多个容器的工具。
Using Compose is basically a three-step process:
Define your app’s environment with a Dockerfile
so it can be reproduced anywhere.
Define the services that make up your app in docker-compose.yml
so they can be run together in an isolated environment.
Run docker-compose up
and Compose starts and runs your entire app.
https://docs.docker.com/compose/compose-file/
按照上面所说的步骤:
1、编写服务的Dockerfile
2、定义docker-compose.yml
version: ‘3‘ services: nginx: hostname: nginx build: context: ./nginx dockerfile: Dockerfile ports: - 81:80 networks: - lnmp volumes: - ./wwwroot:/usr/local/nginx/html php: hostname: php build: context: ./php dockerfile: Dockerfile networks: - lnmp volumes: - ./wwwroot:/usr/local/nginx/html mysql: hostname: mysql image: mysql:5.6 ports: - 3306:3306 networks: - lnmp volumes: - ./mysql/conf:/etc/mysql/conf.d - ./mysql/data:/var/lib/mysql command: --character-set-server=utf8 environment: MYSQL_ROOT_PASSWORD: 123456 MYSQL_DATABASE: wordpress MYSQL_USER: user MYSQL_PASSWORD: user123 networks: lnmp:
3、启动docker-compose
docker-compose -f docker-compose.yml up -d
注意:-d是在后台启动,且要在docker-compose.yml文件目录下启动。
4、查看结果
访问url:http://120.92.*.*:81/wordpress
13、docker-compose快速构建搭建wordpress
标签:running code single png mys www 简单 file you
原文地址:https://www.cnblogs.com/skyflask/p/10140905.html