docker pull docker.io/webdevops/php-nginx
docker pull docker.io/mysql
docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
docker.io/webdevops/php-nginx   latest              2c47c8b5aedb        9 days ago          542 MB
docker.io/mysql                 latest              b8fd9553f1f0        2 weeks ago         445 MB

docker run --name nginx-web -d --network php-net -p 80:80 -v /www/wwwroot/ac:/data  nginx

#外部创建web目录
mkdir -p /home/public_html

docker run -d --name nginx -p 80:80 -v /home/public_html:/home/public_html 2c47c8b5aedb
#报错 Error response from daemon: error creating overlay mount to
#vi /etc/sysconfig/docker-storage
#修改为DOCKER_STORAGE_OPTIONS="--storage-driver overlay"

[root@HostKvm-1e3b70 ~]# docker run -d --name nginx -p 80:80 -v /home/public_html:/home/public_html 2c47c8b5aedb
2723d217b2e49173f419fe79787361636a51013f4c254622b092eeea5435d72f
[root@HostKvm-1e3b70 ~]# doc ps -a
-bash: doc: command not found
[root@HostKvm-1e3b70 ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                   NAMES
2723d217b2e4        2c47c8b5aedb        "/entrypoint super..."   12 seconds ago      Up 11 seconds       443/tcp, 0.0.0.0:80->80/tcp, 9000/tcp   nginx


docker exec -it nginx /bin/bash

#配置相关
include /opt/docker/etc/nginx/global.conf;
include /opt/docker/etc/nginx/php.conf;
include /opt/docker/etc/nginx/conf.d/*.conf;
include /opt/docker/etc/nginx/vhost.conf;
#添加一个
mkdir -p /home/public_html/vhost
/opt/docker/etc/nginx/main.conf
include /home/public_html/vhost/*.conf;


#创建mysql目录

查看docker 官方默认mysql的文档
https://hub.docker.com/_/mysql

支持的标签和相应的Dockerfile链接
8.0.17, 8.0, 8, latest
5.7.27, 5.7, 5
5.6.45, 5.6

docker pull mysql:5.7

去官网看下 https://hub.docker.com/_/mysql

docker run -p 3306:3306 -d --name mysql -v /home/mysql57/data:/var/lib/mysql -v /home/mysql_log:/logs --privileged=true  -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7
docker start mysql

配置文件修改

docker cp mysql:/etc/mysql/mysql.conf.d/mysqld.cnf /home/mysql57/conf

vim /home/mysql57/conf/mysqld.cnf
#添加 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

docker cp /home/mysql57/conf/mysqld.cnf  mysql:/etc/mysql/mysql.conf.d/

docker restart mysql

查看所有容器ip

 docker inspect -f='{{.Name}} {{.NetworkSettings.IPAddress}} {{.HostConfig.PortBindings}}' $(docker ps -aq)
 /mysql57 172.17.0.4 map[3306/tcp:[{ 3306}]]
/es 172.17.0.2 map[9300/tcp:[{ 9300}] 9200/tcp:[{ 9200}]]
/nginx 172.17.0.3 map[80/tcp:[{ 80}]]