docker compose cp
docker-compose exec [service] mysqldump -u [user name] –p [password] [options] [database_name] [tablename] > [dumpfilename.sql]
docker exec -t [hash container] mysqldump -u [user name] –p [password] [options] [database_name] [tablename] > [dumpfilename.sql]
# Database
db:
...
ports:
- 127.0.0.100:3306:3306
...
Игорь, ну, так, очевидно, что nginx блокирует файл. Как именно - не знаю, это зависит от файловой системы и тех операций, что выполняет nginx. То же самое было бы и без докера, будь эти сервисы соседями на одном сервере.
-------------------------------------------------------------------------------
Я бы начал с "open_file_cache off" в конфиге nginx
# Database
db:
image: percona:latest
container_name: myname.db
restart: on-failure
ports:
- 127.0.0.150:3306:3306
expose:
- 3306
environment:
- MYSQL_ROOT_PASSWORD=rdkw1UDddqOEF4L1pmNkcyQ2oL
- MYSQL_DATABASE=mydb
- MYSQL_ROOT_HOST=%
Я так понимаю, что нужно использовать два конфига: docker-dev/docker-prod и nginx/dev nginx/prod
Но я не могу понять как и тот и другой настроить правильно для двух режимов? Можете помочь?
# Development configuration
version: "3.1"
services:
# Php application
app:
container_name: cc.app
build:
context: .
dockerfile: ./docker/php/Dockerfile-dev
restart: on-failure
volumes:
- .:/www
- ./docker/php/log:/var/log
- ./docker/php/usr/local/etc/php/conf.d:/usr/local/etc/php/conf.d
depends_on:
- db
links:
- db
expose:
- 9000
environment:
PHP_INI_SCAN_DIR: ":/usr/local/etc/php/conf.d"
# Database
db:
image: percona:latest
container_name: cc.db
restart: on-failure
ports:
- 127.0.0.160:3306:3306
expose:
- 3306
environment:
- MYSQL_ROOT_PASSWORD=rk3kw1UDdqOEF4L1pmNkcyQ2oL
- MYSQL_DATABASE=cc
- MYSQL_ROOT_HOST=%
# Nginx api server
nginx-api:
container_name: cc.nginx-api
image: nginx:latest
restart: on-failure
volumes:
- ./docker/nginx/dev/nginx.conf:/etc/nginx/nginx.conf
- ./docker/nginx/dev/sites-enabled/vhost-api.conf:/etc/nginx/sites-enabled/vhost-api.conf
ports:
- 127.0.0.160:8090:80
depends_on:
- app
expose:
- 80
command: ["nginx", "-g", "daemon off;"]
# Nginx admin server
nginx-admin:
container_name: cc.nginx-admin
image: nginx:latest
restart: on-failure
volumes:
- ./docker/nginx/dev/nginx.conf:/etc/nginx/nginx.conf
- ./docker/nginx/dev/sites-enabled/vhost-admin.conf:/etc/nginx/sites-enabled/vhost-admin.conf
ports:
- 127.0.0.160:8091:80
depends_on:
- app
expose:
- 80
command: ["nginx", "-g", "daemon off;"]
# Nginx secure server
nginx-secure:
container_name: cc.nginx-secure
image: nginx:latest
restart: on-failure
volumes:
- ./docker/nginx/dev/nginx.conf:/etc/nginx/nginx.conf
- ./docker/nginx/dev/sites-enabled/vhost-secure.conf:/etc/nginx/sites-enabled/vhost-secure.conf
ports:
- 127.0.0.160:8092:80
depends_on:
- app
expose:
- 80
command: ["nginx", "-g", "daemon off;"]
# Production configuration
version: "3.1"
services:
# Php application
app:
container_name: ruintouch.app
restart: always
build:
context: .
dockerfile: ./docker/php/Dockerfile-prod
expose:
- 9000
# Nginx api server
nginx-api:
container_name: ruintouch.nginx-api
image: nginx:latest
restart: always
volumes:
- ./docker/nginx/prod/nginx.conf:/etc/nginx/nginx.conf
- ./docker/nginx/prod/sites-enabled/vhost-api.conf:/etc/nginx/sites-enabled/vhost-api.conf
ports:
- 8095:80
expose:
- 80
command: ["nginx", "-g", "daemon off;"]
# Nginx admin server
nginx-admin:
container_name: ruintouch.nginx-admin
image: nginx:latest
restart: always
volumes:
- ./docker/nginx/prod/nginx.conf:/etc/nginx/nginx.conf
- ./docker/nginx/prod/sites-enabled/vhost-admin.conf:/etc/nginx/sites-enabled/vhost-admin.conf
ports:
- 8096:80
expose:
- 80
command: ["nginx", "-g", "daemon off;"]
#Nuxt publication
nuxt-public:
container_name: ruintouch.nuxt_public
restart: always
build:
context: ./nuxt_public
dockerfile: Dockerfile-prod
ports:
- "3001:3000"
expose:
- "3000"
[mysqld]
explicit_defaults_for_timestamp = 1
# Development configuration
version: "3.1"
services:
app:
container_name: rusaddress.app
build:
context: .
dockerfile: ./docker/php/Dockerfile-dev
volumes:
- .:/www
- ./docker/php/log:/var/log
depends_on:
- db
links:
- db
expose:
- 9000
# Nginx api server
nginx-api:
container_name: rusaddress.nginx-api
restart: always
build: ./docker/nginx
volumes:
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./docker/nginx/sites-enabled/vhost-api.rusaddress.conf:/etc/nginx/sites-enabled/vhost-api.rusaddress.conf
ports:
- "127.0.0.150:8090:90"
depends_on:
- app
expose:
- "90"
command: ["nginx", "-g", "daemon off;"]
...
server {
listen 90;
client_max_body_size 208M;
access_log /var/log/nginx/api.access.log;
root /www/public;
location / {
try_files $uri $uri/ /api.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index api.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
server {
listen %ip%:%httpport%;
server_name api.rusaddress.local;
access_log "%sprogdir%/userdata/logs/api.rusaddress.local.access.log combined";
error_log "%sprogdir%/userdata/logs/api.rusaddress.local.error.log error";
add_header "Access-Control-Allow-Origin" "*";
add_header "Access-Control-Allow-Headers" "Origin, X-Requested-With, Content-Type, Accept, Authorization";
add_header "Access-Control-Request-Methods" "GET, POST, OPTIONS";
location / {
proxy_pass http://127.0.0.150:8090;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
$ErrorActionPreference = "SilentlyContinue"
kill -force -processname 'Docker for Windows', com.docker.db, vpnkit, com.docker.proxy, com.docker.9pdb, moby-diag-dl, dockerd
try {
./MobyLinux.ps1 -Destroy
} Catch {}
$service = Get-WmiObject -Class Win32_Service -Filter "Name='com.docker.service'"
if ($service) { $service.StopService() }
if ($service) { $service.Delete() }
Start-Sleep -s 5
Remove-Item -Recurse -Force "~/AppData/Local/Docker"
Remove-Item -Recurse -Force "~/AppData/Roaming/Docker"
if (Test-Path "C:\ProgramData\Docker") { takeown.exe /F "C:\ProgramData\Docker" /R /A /D Y }
if (Test-Path "C:\ProgramData\Docker") { icacls "C:\ProgramData\Docker\" /T /C /grant Administrators:F }
Remove-Item -Recurse -Force "C:\ProgramData\Docker"
Remove-Item -Recurse -Force "C:\Program Files\Docker"
Remove-Item -Recurse -Force "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Docker"
Remove-Item -Force "C:\Users\Public\Desktop\Docker for Windows.lnk"
Get-ChildItem HKLM:\software\microsoft\windows\currentversion\uninstall | % {Get-ItemProperty $_.PSPath} | ? { $_.DisplayName -eq "Docker" } | Remove-Item -Recurse -Force
Get-ChildItem HKLM:\software\classes\installer\products | % {Get-ItemProperty $_.pspath} | ? { $_.ProductName -eq "Docker" } | Remove-Item -Recurse -Force
Get-Item 'HKLM:\software\Docker Inc.' | Remove-Item -Recurse -Force
Get-ItemProperty HKCU:\software\microsoft\windows\currentversion\Run -name "Docker for Windows" | Remove-Item -Recurse -Force
#Get-ItemProperty HKCU:\software\microsoft\windows\currentversion\UFH\SHC | ForEach-Object {Get-ItemProperty $_.PSPath} | Where-Object { $_.ToString().Contains("Docker for Windows.exe") } | Remove-Item -Recurse -Force $_.PSPath
#Get-ItemProperty HKCU:\software\microsoft\windows\currentversion\UFH\SHC | Where-Object { $(Get-ItemPropertyValue $_) -Contains "Docker" }
Set-ExecutionPolicy RemoteSigned
.\remove-docker.ps1