用 Docker 製作的 Laravel 開發環境

創業的掃地僧發表於2019-12-24

自己基於centos7.6.1810和寶塔7.0.12製作的docker映象,600多M,將通過 Docker 在個人本地電腦上構建一個快速、輕量級、不依賴本地電腦所安裝的任何開發套件的可複製的 Laravel 和 Vue 專案的開發環境
希望前輩能指導我是思維慣性 下面是我自己在用的很婁的指令碼
求職 個人成長經歷 1年 PHP,求點化
環境k8s叢集外
一鍵部署: docker login

#使用—>製作映象->停止容器—>刪除容器->上傳映象->執行映象容器-> 工作一小時 休息10分鐘 每天進步一點點

############# 增 #############
docker run \ 
--name tp5.1 \ 
--privileged=true \ 
--restart always \ 
-itd \ 
-p 21:21 \ 
-p 80:80 \ 
-p 443:443 \ 
-p 888:888 \ 
-p 3306:3306 \ 
-p 6379:6379 \ 
-p 8888:8888 \ 
-p 9501:9501 \ 
-p 9508:9508 \ 
-p 18306:18306 \ 
-p 18307:18307 \
1872220587/bt:centos7.6.1810..Bt7.0.12..tp5.1..v1.1..Study
#-v /mnt/wwwroot:/www/wwwroot 
#本地windocs目錄->共享給區域網windocs->共享給虛擬機器linux->docker -v <—>nfs.sh 
docker exec -it tp5.1 /bin/bash #使用
#kubectl exec -it cloud-centos-0 /bin/bash
#服務啟動
bt 1
/etc/init.d/nginx start
/etc/init.d/mysqld start
/etc/init.d/pure-ftpd start
/etc/init.d/php-fpm-56 start
/etc/init.d/php-fpm-73 start
/etc/init.d/redis restart
#   end 使用—>製作映象->停止容器—>刪除容器->上傳映象->執行映象容器-> 工作一小時 休息10分鐘 每天進步一點點 

#專案初始化   常用操作
############# 改  #############
#docker exec -it tp5.1 /bin/bash #使用
kubectl exec -it cloud-centos-0 /bin/bash
cd /www/wwwroot
rm -rf tp5.zhaofa.love
#mkdir tp5.zhaofa.love
git clone https://gitee.com/heyingmin/xhcms2.git tp5.zhaofa.love
composer create-project topthink/think=5.1.x-dev tp5.zhaofa.love
cd /www/wwwroot/tp5.zhaofa.love

#
#所有輸出都被重定向到一個名為nohup.out的檔案中
command > out.file 2>&1 & 
nohup command > nohup.out 2>&1 &
nohup php think swoole &
nohup php think swoole:server &
nohup php easyswoole start &

#日常學習
docker commit -a "1872220587" -m "tp5.1學習" tp5.1 1872220587/bt:centos7.6.1810..Bt7.0.12..tp5.1..v1.0..Study #提交'''
docker push 1872220587/bt:centos7.6.1810..Bt7.0.12..tp5.1..v1.1..Study #上傳

############# 刪 #############
docker restart tp5.1 #重啟
docker stop tp5.1 #停止
docker rm tp5.1 #刪除

#刪除所有未被容器使用的映象:
docker image prune -a
#刪除所有停止執行的容器:
docker container prune
#刪除所有未被掛載的卷:
docker volume prune
#刪除所有網路:
docker network prune

環境k8s叢集內




---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  annotations:
    k8s.eip.work/displayName: centoss
    k8s.eip.work/ingress: 'true'
    k8s.eip.work/service: NodePort
    k8s.eip.work/workload: cloud-centoss
  creationTimestamp: '2019-12-04T20:30:21Z'
  generation: 7
  labels:
    k8s.eip.work/layer: cloud
    k8s.eip.work/name: cloud-centoss
  name: cloud-centoss
  namespace: default
  resourceVersion: '5214645'
  selfLink: /apis/apps/v1/namespaces/default/statefulsets/cloud-centoss
  uid: bcb38a2d-ef89-48de-80a4-ff9d5e1ff57b
spec:
  podManagementPolicy: OrderedReady
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      k8s.eip.work/layer: cloud
      k8s.eip.work/name: cloud-centoss
  serviceName: cloud-centoss
  template:
    metadata:
      labels:
        k8s.eip.work/layer: cloud
        k8s.eip.work/name: cloud-centoss
    spec:
      containers:
        - image: '1872220587/bt:centos7.6.1810..Bt7.0.12..tp5.1..v1.1..Study'
          imagePullPolicy: IfNotPresent
          name: centoss
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /www/wwwroot/tp5.zhaofa.love
              mountPropagation: HostToContainer
              name: centoss
              subPath: tp5.zhaofa.love
            - mountPath: /www/wwwroot/laravel.zhaofa.love
              mountPropagation: HostToContainer
              name: centoss
              subPath: laravel.zhaofa.love
            - mountPath: /www/wwwroot/web.zhaofa.love
              mountPropagation: HostToContainer
              name: centoss
              subPath: web.zhaofa.love
      dnsPolicy: ClusterFirst
      nodeName: node1
      restartPolicy: Always
      schedulerName: default-scheduler
      terminationGracePeriodSeconds: 30
      volumes:
        - name: centoss
          persistentVolumeClaim:
            claimName: default
  updateStrategy:
    rollingUpdate:
      partition: 0
    type: RollingUpdate
status:
  collisionCount: 0
  currentReplicas: 1
  currentRevision: cloud-centoss-7bcb7b74f8
  observedGeneration: 7
  readyReplicas: 1
  replicas: 1
  updateRevision: cloud-centoss-7bcb7b74f8
  updatedReplicas: 1

---
apiVersion: v1
kind: Service
metadata:
  annotations:
    k8s.eip.work/displayName: centoss
    k8s.eip.work/workload: cloud-centoss
  creationTimestamp: '2019-12-04T20:30:21Z'
  labels:
    k8s.eip.work/layer: cloud
    k8s.eip.work/name: cloud-centoss
  name: cloud-centoss
  namespace: default
  resourceVersion: '4743644'
  selfLink: /api/v1/namespaces/default/services/cloud-centoss
  uid: 879c4fbf-1538-4042-8d5a-5cd7717cae78
spec:
  clusterIP: 10.1.57.173
  externalTrafficPolicy: Cluster
  ports:
    - name: m4ws5x
      nodePort: 32678
      port: 8888
      protocol: TCP
      targetPort: 8888
    - name: rg7ccs
      nodePort: 30579
      port: 80
      protocol: TCP
      targetPort: 80
    - name: qq3rgw
      nodePort: 32460
      port: 21
      protocol: TCP
      targetPort: 21
    - name: fjc2wj
      nodePort: 32310
      port: 3306
      protocol: TCP
      targetPort: 3306
    - name: sgcbpm
      nodePort: 31170
      port: 888
      protocol: TCP
      targetPort: 888
    - name: 7j7mfq
      nodePort: 30366
      port: 443
      protocol: TCP
      targetPort: 443
  selector:
    k8s.eip.work/layer: cloud
    k8s.eip.work/name: cloud-centoss
  sessionAffinity: None
  type: NodePort

---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    k8s.eip.work/displayName: centoss
    k8s.eip.work/workload: cloud-centoss
  creationTimestamp: '2019-12-04T20:32:34Z'
  generation: 9
  labels:
    k8s.eip.work/layer: cloud
    k8s.eip.work/name: cloud-centoss
  name: cloud-centoss
  namespace: default
  resourceVersion: '4821923'
  selfLink: /apis/networking.k8s.io/v1beta1/namespaces/default/ingresses/cloud-centoss
  uid: 204a3138-4536-4880-a113-391be2f6b454
spec:
  rules:
    - host: bt.zhaofa.love
      http:
        paths:
          - backend:
              serviceName: cloud-centoss
              servicePort: m4ws5x
            path: /
    - host: tp5.zhaofa.love
      http:
        paths:
          - backend:
              serviceName: cloud-centoss
              servicePort: rg7ccs
            path: /
    - host: laravel.zhaofa.love
      http:
        paths:
          - backend:
              serviceName: cloud-centoss
              servicePort: rg7ccs
            path: /
    - host: mysql.zhaofa.love
      http:
        paths:
          - backend:
              serviceName: cloud-centoss
              servicePort: rg7ccs
            path: /
    - host: shop.zhaofa.love
      http:
        paths:
          - backend:
              serviceName: cloud-centoss
              servicePort: rg7ccs
            path: /
    - host: www.zhaofa.love
      http:
        paths:
          - backend:
              serviceName: cloud-centoss
              servicePort: rg7ccs
            path: /
    - host: tp6.zhaofa.love
      http:
        paths:
          - backend:
              serviceName: cloud-centoss
              servicePort: rg7ccs
            path: /
    - host: web.zhaofa.love
      http:
        paths:
          - backend:
              serviceName: cloud-centoss
              servicePort: rg7ccs
            path: /
    - host: zhaofa.love
      http:
        paths:
          - backend:
              serviceName: cloud-centoss
              servicePort: rg7ccs
            path: /

相關文章