小日日

Stay hungry,stay foolish

0%

docker

容器内安装Composer

镜像容器运行后,在容器内安装 Composer

1
2
3
4
5
6
7
8
9
wget https://github.com/composer/composer/releases/download/1.8.6/composer.phar
chmod u+x composer.phar
mv composer.phar /usr/local/bin/composer

将 Composer 镜像设置为 阿里云 镜像,加速国内下载速度

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

php -r "echo ini_get('memory_limit').PHP_EOL;"

Docker安装xdebug调试

创建容器
docker run -d -p 10100:80 –name xici-form -v D:\www\project\job-talen:/var/www/html registry.cn-hangzhou.aliyuncs.com/alicode/php72

docker run -d -p 20001:9501 –name xici-forum-swoole -v /mnt/d/www/project/xici_forum:/www registry.cn-hangzhou.aliyuncs.com/lykj/swoole-php:php-7.2.1-swoole4.3.3 http

docker run –name web -p 80:80 -v /mnt/d/www/config/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx

安装xdebug
pecl install xdebug
编辑配置文件
/usr/local/etc/php/php.ini

// 2.x
[xdebug]
zend_extension=”/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so”
xdebug.remote_enable=1
xdebug.remote_host=host.docker.internal
xdebug.remote_port=9000

//3.x
[xdebug]
zend_extension=”/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so”
xdebug.mode=debug
xdebug.client_host=host.docker.internal
xdebug.client_port=9000

修改完要重启

postman get参数
XDEBUG_SESSION_START=PHPSTORM

服务器路径映射对应docker容器内容的路径(远程服务器的路径)
docker run -d –name wallpaper -v C:/Users/xiaoriri/Desktop/code/wallpaper-api:/data/project -p 9501:9501 -it –privileged -u root –entrypoint /bin/sh hyperf/hyperf:7.4-alpine-v3.11-swoole

k8s创建证书

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj “/CN=wallpaper.xiaoriri.com/O=wallpaper.xiaoriri.com”
kubectl create secret tls wallpaper.xiaoriri.com –key tls.key –cert tls.crt

swarm部署

创建配置文件

1
2
3
docker config creaete name file_path

docker service create --name wallpaper -p 9501:9501 --config src=wallpaper,target="/opt/www/.env" registry.cn-hangzhou.aliyuncs.com/xiaoriri/wallpaper:dev

滚动更新

1
docker service update --with-registry-auth --image registry.cn-hangzhou.aliyuncs.com/xiaoriri/wallpaper:dev wallpaper

伸缩容器

1
docker service scale masl=2 #masl是service名称

Docker restart 策略

官方文档

docker run –restart=always 容器ID

docker update –restart=always 容器ID

删除指定前缀容器

docker rm -f $(docker ps -a | grep “wall*” | awk ‘{print $1}’)