docker images 查看当前又那些镜像
docker ps 查看启动的容器
docker ps -a 查看所有容器
docker logs 容器的id 以及容器名称 查看容器日志
docker top 容器的id 以及 容器名称 查看容器进程
第一步首先下载docker
yum -y install docker
yum -y install vim
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://ftnejmh3.mirror.aliyuncs.com"]
}
然后退出并保存
:wq
service docker start
docker images
第二部拉取nginx
docker pull nginx
创建一个docker目录
然后进入docker
给nginx配置文件
:wq
server {
listen 80;
listen [::]:80;
server_name localhost;
root /docker/www/lmrs-2008/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /docker/www/lmrs-2008/public;
}
location ~ \.php$ {
root /docker/www/lmrs-2008/public;
fastcgi_pass 172.17.0.3:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
然后构建nginx进程
docker run -p 80:80 -d --name nginx -v /docker/www:/docker/www -v /docker/nginx/default.conf:/etc/nginx/conf.d/default.conf --privileged=true nginx
第三步拉取php
docker pull php:7.4-fpm
docker run -p 9000:9000 -d --name php -v /docker/www:/docker/www --privileged=true php:7.4-fpm
一般都出现在nginx配置文件里
cat命令是打印 vim命令是编辑 先改成这样后面项目在调整
docker restart nginx
进入nginx容器里面
docker exec -it nginx bash
cat /etc/nginx/conf.d/default.conf
docker run -p 80:80 -d --name nginx -v /docker/www:/docker/www -v/docker/nginx
/default.conf:/etc/nginx/conf.d/default.conf --privileged=true nginx
docker inspect php |grep "Address"
docker restart nginx
代表映射成功
未完待续
接下来拉取mysql
docker pull mysql
拉取redis
docker pull redis
docker images
然后我们映射mysql
首先打印我们的mysql 配置
cat /etc/my.cnf
vim /etc/my.cnf
:%d
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
secure_file_priv=/var/lib/mysql
port = 3306
socket = /tmp/mysql.sock
datadir = /usr/local/mysql/data
default_storage_engine = InnoDB
performance_schema_max_table_instances = 400
table_definition_cache = 400
skip-external-locking
key_buffer_size = 32M
max_allowed_packet = 100G
table_open_cache = 128
sort_buffer_size = 768K
net_buffer_length = 4K
read_buffer_size = 768K
read_rnd_buffer_size = 256K
myisam_sort_buffer_size = 8M
thread_cache_size = 16
tmp_table_size = 32M
default_authentication_plugin = mysql_native_password
lower_case_table_names = 1
sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
explicit_defaults_for_timestamp = true
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
binlog_expire_logs_seconds = 600000
slow_query_log=1
slow-query-log-file=/usr/local/mysql/data/mysql-slow.log
long_query_time=3
early-plugin-load = ""
innodb_data_home_dir = /usr/local/mysql/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/data
innodb_buffer_pool_size = 128M
innodb_log_file_size = 64M
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
innodb_max_dirty_pages_pct = 90
innodb_read_io_threads = 1
innodb_write_io_threads = 1
[mysqldump]
quick
max_allowed_packet = 500M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 32M
sort_buffer_size = 768K
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
将这些文件复制进去 然后
:wq保存
可以通过
cat /etc/my.cnf
进行打印
docker run -p 3306:3306 -d --name mysql -v /etc/my.cnf:/etc/mysql/my.cnf --privileged=true -e MYSQL_ROOT_PASSWORD=root mysql
映射成功
docker logs mysql
docker start mysql
启动mysql
docker ps -a
这里可以看见容器已经启动
然后我们进入容器 启动mysql
这里可以查看数据库的权限
最后开启我们的redis
可能我这里只是开启 所以配置上懒得配置了 但是不妨碍使用 后面还会调整到文章里
docker run -p 6379:6379 -d --name redis --privileged=true redis
swoole下载地址
https://pecl.php.net/package/swoole
然后我下载的是4.66版本
下载后将压缩包放在
注意一下权限
注意我只是开了两个端口 去解压swoole
tar -zxvf swoole-4.6.6.tgz
docker cp swoole-4.6.6 php:/usr/src/php/ext/swoole
docker-php-ext-install swoole
php --ri swoole