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



mkdir -p /home/mysql57/data
mkdir -p /home/mysql57/conf
mkdir -p /home/mysql57/log

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

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

[root@HostKvm-1e3b70 ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                            NAMES
9f8866788af2        mysql               "docker-entrypoint..."   18 seconds ago      Up 17 seconds       0.0.0.0:3306->3306/tcp, 33060/tcp                mysql
9de99158a63f        9c3858684801        "/usr/local/bin/do..."   10 hours ago        Up 10 hours         0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   es
2723d217b2e4        2c47c8b5aedb        "/entrypoint super..."   32 hours ago        Up 10 hours         443/tcp, 0.0.0.0:80->80/tcp, 9000/tcp            nginx


docker exec -it mysql57 /bin/bash

touch /home/mysql57/conf/my.cnf
vim /home/mysql57/conf/my.cnf

[mysqld]
#skip-grant-tables
log-error = /logs/mysql-error.log
#config by shw
max_connections = 100
table_open_cache = 30
max_allowed_packet = 16M
max_heap_table_size = 16M
sort_buffer_size = 16M
join_buffer_size = 8M
query_cache_type = 1
query_cache_size = 16M
query_cache_limit = 2M
slow_query_log = 1
slow_query_log_file = /logs/slow.log
long_query_time = 2
innodb_purge_threads = 1
thread_cache_size = 1
innodb_read_io_threads=5
innodb_write_io_threads=5
#MyISAM config
key_buffer_size = 128M
read_buffer_size = 64M
read_rnd_buffer_size = 16M
myisam_max_sort_file_size = 1G
myisam_repair_threads = 4
#innodb config
innodb_buffer_pool_size = 256M
innodb_log_buffer_size = 16M
innodb_log_file_size = 16M
innodb_lock_wait_timeout = 30

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

#重启一下mysql
docker restart mysql57

#挂了,把日志目录 修改下, 记录非编译mysql日志目录的seliunx强制了 要挂在var/lib/mysql 或 var/log/mysql 不能设置其它 
log-error = /var/lib/mysql/mysql-error.log
slow_query_log_file = /var/lib/mysql/slow.log

#果然ok了
[root@HostKvm-1e3b70 conf]# docker restart mysql57
mysql57
[root@HostKvm-1e3b70 conf]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                            NAMES
97735b0bbf71        mysql:5.7           "docker-entrypoint..."   15 minutes ago      Up 3 seconds        0.0.0.0:3306->3306/tcp, 33060/tcp                mysql5

#重置下root密码 就准备用了

查看所有容器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}]]