• docker相关命令


    #-----------------------------------php运行环境------------------------
    #载入镜像
    docker load < centos_php7.rar
    
    #php运行环境容器
    docker run --restart=always -p 80:80 -d -e "container=docker" --privileged=true -v /mnt/www/log:/var/log -v /mnt/www/newgks.dahuasecurity.com:/usr/share/nginx/html -v /mnt/www/conf/nginx/nginx.conf:/etc/nginx/nginx.conf -v /mnt/www/conf/nginx/conf.d:/etc/nginx/conf.d -v /mnt/www/conf/php/etc:/usr/local/php/etc -v /mnt/www/conf/php/php.ini:/usr/local/php/lib/php.ini --name centos7 centos_php73 /usr/sbin/init
    
    docker run --restart=always -p 80:80 -d -e "container=docker" --privileged=true -v /mnt/www/newgks.dahuasecurity.com:/usr/share/nginx/html -v /mnt/www/conf/nginx/nginx.conf:/etc/nginx/nginx.conf -v /mnt/www/conf/nginx/conf.d:/etc/nginx/conf.d -v /mnt/www/conf/php/etc:/usr/local/php/etc -v /mnt/www/conf/php/php.ini:/usr/local/php/lib/php.ini --name centos7 php73 /usr/sbin/init
    
    #wwwroot
    docker run --restart=always -p 80:80 -d -e "container=docker" --privileged=true -v /wwwroot/log:/var/log -v /wwwroot/website/newgks.dahuasecurity.com:/usr/share/nginx/html -v /mnt/www/newgks.dahuasecurity.com/public/asset:/usr/share/nginx/html/public/asset  -v /wwwroot/conf/nginx/nginx.conf:/etc/nginx/nginx.conf -v /wwwroot/conf/nginx/conf.d:/etc/nginx/conf.d -v /wwwroot/conf/php/etc:/usr/local/php/etc -v /wwwroot/conf/php/php.ini:/usr/local/php/lib/php.ini --name centos7 php73 /usr/sbin/init
    
    #设置附件软链接
    ln -s /mnt/www/newgks.dahuasecurity.com/public/asset /usr/share/nginx/html/public/asset
    
    #进入容器
    docker exec -it centos7 /bin/bash
    
    #重启容器
    docker restart centos7
    
    #停止并删除容器
    docker stop centos7
    docker rm centos7
    
    #打包docker
    docker commit -m "php7.3环境" -a "jason,511594105@qq.com" centos7 php73
    docker save > php73.tar php73:latest
    #载入镜像
    docker load < php73.tar
    #停止并删除容器
    docker stop centos7 && docker rm centos7
    #-----------------------------------php运行环境------------------------
    
    
    #--------------------redis--------------------
    docker run --restart=always -p 6379:6379 --privileged=true -v /mnt/www/conf/redis.conf:/etc/redis/redis.conf --name myredis --restart=always -d redis redis-server /etc/redis/redis.conf
    
    #导出镜像
    docker save > redis.tar redis:latest
    #--------------------redis--------------------
    
    #--------------------nginx安装--------------------
    #添加nginx的源
    rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    #安装nginx
    yum install -y nginx
    #启动
    systemctl start nginx.service
    #设置开机启动
    systemctl enable nginx.service
    #--------------------nginx安装--------------------
    
    
    # ----------------------------dockers 安装-------------------------------
    切换到root用户
    sudo -s
    下载wget
    yum install wget -y
    mkdir -p  /etc/yum.repos.d
    
    #下载阿里云yum源配置
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    #更新缓存
    yum clean all
    yum makecache
    
    #安装前置条件
    #docker要求Linux内核要3.0以上版本,如果centos6.x 内核是2.x,需要升级linux内核
    #我虚拟机直接安装的是centos 7 64位 输入uname -r 查看内核
    
    #安装步骤
    #升级本地yum包
    yum update
    #安装工具集
    yum install -y yum-utils device-mapper-persistent-data lvm2
    #安装阿里云docker源
    sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    #更新yum缓存
    yum makecache fast
    yum clean  all
    #安装docker
    yum -y install docker-ce
    #启动docker服务
    service docker start
    #查看docker版本
    docker -v
    #开机启动docker服务
    systemctl enable docker.service
    
    
    #编辑任务
    crontab -e
    #查看任务
    crontab -l
    
    #每天23点执行删除压缩包操作
    * 23 * * * curl https://gks.dahuasecurity.com/frontInterface/Asynchronous/file_zip_del
    #每1小时执行新文件标识
    * */1 * * * curl http://10.1.85.218/frontInterface/Asynchronous/file_new
    #每5分钟执行一次上传S3操作
    */5 * * * * curl http://10.1.85.218/frontInterface/Asynchronous/file_s3_python
    
    * */2 * * * curl http://10.1.85.218/frontInterface/asynchronous/update_employee
    
    * */3 * * * curl http://10.1.85.218/frontInterface/asynchronous/handle_error_list
    #日志处理,出队
    */1 * * * * curl http://10.1.85.218/frontInterface/asynchronous/log_pop
    
    
    
    sudo -s
    docker restart centos7
    
    
    #没有python-pip包就执行命令
    yum -y install epel-release
    yum -y install python-pip
    
    #对安装好的pip进行升级
    pip install --upgrade pip
    pip install pymysql
    pip install boto3
    
    
    
    #--------------------基本操作--------------------
    #查看运行中的容器
    docker ps
    #查看所有容器
    docker ps -a
    #重启容器
    docker restart mysql
    #进入容器
    docker exec -it mysql /bin/bash
    #停止容器
    docker stop mysql
    #启动容器
    docker start mysql
    #删除容器
    docker rm mysql
    #把容器打包成镜像
    #查看容器
    docker images
    docker save > mysql.tar mysql
    
    #拉取镜像
    docker pull mysql:5.7
    #载入镜像
    docker load < mysql.tar
    #查看镜像
    docker images
    #删除镜像
    docker rmi mysql
    
    systemctl restart php-fpm
  • 相关阅读:
    使用ConcurrentHashMap需要知道的细节
    并查集(Union-Find)
    LeetCode2
    补充之前博客的几种排序--希尔排序、堆排序、归并排序
    左式二叉堆
    优先队列的一种实现--堆ADT
    开放地址法散列表ADT
    分离链表法散列ADT
    AVL树
    二叉查找树ADT--C语言描述
  • 原文地址:https://www.cnblogs.com/guliang/p/14267594.html
Copyright © 2020-2023  润新知