docker-compose rapid deployment environments notes

# Construction container containing at docker-compose.yml file folder
# Dockerfile if used to execute the application again after modifying Dockerfile modified file
docker-compose up -d

all containers #STOP docker-compose.yml inside
docker- STOP Compose

# delete docker-compose.yml inside all containers
docker-compose RM

# View docker-compose.yml inside nginx log
docker-compose nginx logs -f

# restart docker-compose.yml inside a container of a
docker-compose nginx restart
#### start stop start stop #####
----------------
Disclaimer: This article is the original article CSDN bloggers "promiscuous Dian", following the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/q85795362/article/details/82770670

 

I question the use of the process is mainly encountered nginx cgi and php extension issue, and finally succeeded after repeated several times to install.

 

1, the use of docker-compose rm delete a container, by up -d install again, found the old data in the container or before

Solution: docker stop <container> docker rmi <image>

 

2, configure the environment by good returns a blank page nginx access php, html file returns to normal

Solution:

Check your file contains nginx.conf

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

If it does not, please put a few lines of code below into include fastcgi_params

 

3, after completing the operation in step 2 or no effect

This could be php-fpm not refresh over, you can restart php environment by docker restart php72 command and refresh extension

 

4, delete the docker-compose container also deleted docker image, when again installed inside containers or old data

Solution: This is the question before different, sloppy due, mysql, redis, nginx yml file volumes defined in the / home / docker / under, but I forgot to sync again pulling git source code in / root / in to these directories, so he has been led to the initial version of the content, each time pulling git source

Re-set about these directories * .conf files just fine

 

Docker-compose I use is downloaded from the official website of the Docker, yml deployment environment is downloaded from here (Note that authors get rid of the port number, remember to change it back) https://gitee.com/imtellyou/docker -compose

docker-compose.yml file I use contains php7.2, php-redis, php-bopche, redis, mysql5.7, phpmyadmin:

Version: '2'
Services:
mysql:
Build: ./mysql # Dockerfile file using
the ports:
- "3306: 3306" port # host: port container
Environment:
- Set # 123456 MYSQL_ROOT_PASSWORD = mysql root password
Volumes:
- / Home / docker / mysql / data: / var / lib / mysql: rw # mysql data files
- /home/docker/mysql/my.cnf:/etc/my.cnf
networks:
- # nET-added network MySQL
container_name: mysql57 # settings container name
Redis:
Build: ./redis
the ports:
- "127.0.0.1:6379:6379" # without access to the container inside as outside the network service is set to ip address 127.0.0.1
Environment:
- open appendOnly = yes # redis password
- requirepass = 123456 # set password redis
Networks:
- redis-NET
CONTAINER_NAME: redis40
PHP:
Build: ./php
the ports:
- "127.0.0.1:9000:9000"
Volumes:
- / Home / Docker / Web: / var / the WWW / HTML: rw # Web site directory
- / home / docker / php / php .ini: /usr/local/etc/php/php.ini: ro #php profile
- /home/docker/php/www.conf:/usr/local/etc/php-fpm.d/www.conf: ro # php-fpm profile
Networks:
- PHP-NET
- MySQL-NET
- Redis-NET
CONTAINER_NAME: php72
nginx:
Build: ./nginx
the ports:
- "80:80" if the host has mounted # nginx or apache and running you need to be mapped to other ports
- "81:81" # set multiple sites
- "82:82"
- "83:83"
depends_on:
- "PHP"
Volumes:
- / Home / Docker / Web: / var / the WWW / html: rw
- /home/docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- /home/docker/nginx/server.conf:/etc/nginx/conf.d/default.conf:ro
- /home/docker/nginx/fastcgi_params:/etc/nginx/fastcgi_params:ro
networks:
- php-net
container_name : nginx114
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
container_name: my-phpmyadmin
ports:
- "84:80"
environment:
MYSQL_USER: "root"
MYSQL_PASSWORD: "?CC;XDgqU5NX"
MYSQL_ROOT_PASSWORD: "?CC;XDgqU5NX"
PMA_HOST: mysql57
networks:
- mysql-net
networks: # 创建网络
php-net:
mysql-net:
redis-net:

I nginx.conf file used:

server {
listen 80;
server_name 127.0.0.1;
root /var/www/html;
index index.html index.htm index.php;

location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
autoindex off;
}

location ~ \.php(.*)$ {
fastcgi_pass php72:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "(.+?\.php(/.*))") {
set $real_script_name $1;
set $path_info $2;
}
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

If you do not use docker to build environment, it is recommended to use this framework oneinstack automated deployment environment, both of which are very convenient and save a lot of time

Guess you like

Origin www.cnblogs.com/renhongwei/p/11570016.html