Posted in Docker
6335
3:47 am, June 16, 2022
 

What's the Point of Docker?

What's the Point of Docker?

These are my notes on installing docker on a VPS, there a bit jumbled, but mostly a full collection of the commands i used to get docker working with docker config. Also a lot of links to external sources that i got a lot of the config info from. 

Getting Started With Docker On Your VPS (Tutorial) | Serverwise

Getting started with Docker on your VPS is pretty straightforward, and once you're set up via this Docker tutorial, it's like you've "leveled up" in DevOps. Docker is a platform for designing, building, and launching "containers," which are isolated environments containing all the software and configuration files necessary to run a service or application. Link. 
 

So what is the point of docker?

  • Develop locally using a custom or specific environment.
  • Make sure that the local dev environment is the same as the live deployed environment. 
  • Setup docker files or docker images to make sure your apps have redundancy or fail overs in case of server errors or application errors. 
  • Run multiple applications on a VPS without them conflicting with each other as they are seperated on the same system. 
  • Stop one crash taking the whole server down, if you have a fault in one container it should not effect other containers on the same machine. 
  • Dont restart your server but restart the container, with out effecting other containers on the same server. 
  • Better Security as most containers run specific environments that are rebuilt only using docker so nothing touches the pre built docker systems. 
 

Prune Images

Incase your docker images are taking up too much space you can run this

Prune images
perge images

docker image prune -a

     

    Docker Hub

    Docker Hub allows you to share and save your custom images and load a library of existing images. Link

     

    Installing Docker on Ubuntu 16, 18, 20

    ubuntu 18 command line install

    guide to installing docker on ubuntu 20

    How To Install and Use Docker on Ubuntu 20.04 

    Docker is an application that simplifies the process of managing application processes in containers. Containers let you run your applications in resource-isolated processes. They're similar to virtual machines, but containers are more portable, more resource-friendly, and more dependent on the host operating system. Link.

    Pi 400 Docker

    I tried getting docker up and running also on the pi400 but as its arm based i came across some issues running normal docker containers, assuming this is due to the images being intel or amd based. 

    Local domain

    To create a .local domain, install Avahi Daemon on your Pi;
    
    sudo apt-get install avahi-daemon
    
    By default, the hostname is raspberrypi.

    Install Docker-Compose on Raspberry Pi - JFrog Connect (formerly Upswift)

    Docker containers are light-weight, requires minimal resources and makes it possible to deliver your software quicker, which makes them extremely useful for SBC's such as Raspberry Pi. How do we define and run multi-container docker applications? Docker-Compose is the answer. Link.
     

    Install Docker on Rasberry Pi

    install docker
    
    curl -fsSL https://get.docker.com -o get-docker.sh
    
    sudo sh get-docker.sh
    
    ‍sudo usermod -aG docker ${USER}
    
    check if its in the group
    
    groups ${USER}
    
    su the user or logout and back in
    
    test if docker is working
    
    docker version
    
    ‍docker info
    
    docker run hello-world
    
    docker image rm hello-world

    Docker Compose on pi400

    sudo apt-get install libffi-dev libssl-dev
    sudo apt install python3-dev
    sudo apt-get install -y python3 python3-pip
    
    ‍sudo pip3 install docker-compose
    
    ‍sudo systemctl to enable Docker??
    

    sudo apt update
    
    sudo apt install apt-transport-https ca-certificates curl software-properties-common
    
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
    
    apt-cache policy docker-ce
    
    sudo apt install docker-ce
    
    sudo systemctl status docker

    Docker Installing

    Docker Running

    sudo usermod -aG docker kruxor
    
    sudo usermod -aG docker ${USER}
    
    su - ${USER}
    
    groups
    
    docker info
    
    docker run hello-world

    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    2db29710123e: Pull complete 
    Digest: sha256:10d7d58d5ebd2a652f4d93fdd86da8f265f5318c6a73cc5b6a9798ff6d2b2e67
    Status: Downloaded newer image for hello-world:latest
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (amd64)
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
    
    To try something more ambitious, you can run an Ubuntu container with:
     $ docker run -it ubuntu bash
    
    Share images, automate workflows, and more with a free Docker ID:
     https://hub.docker.com/
    
    For more examples and ideas, visit:
     https://docs.docker.com/get-started/

    docker search ubuntu

    docker pull ubuntu
    show images
    docker images
    docker run ubuntu

    run ubuntu image with an interactive shell

    docker run -it ubuntu

    install node on this new instance of ubuntu

    copy the instance id as well

    docker run -it ubuntu
    
    #007f6db6d204
    
    apt update
    
    apt install nodejs
    
    node -v
    
    #Any changes you make inside the container only apply to that container.

    show all containers
    docker ps -a
    docker ps -l
    
    #start a container by id
    docker start 007f6db6d204
    docker run -it sleepy_wiles
    docker run -it 007f6db6d204

    commit changes to image

    requires a docker hub user id

    docker commit -m "What you did to the image" -a "Author Name" container_id repository/new_image_name
    
    docker commit -m "added Node.js" -a "sammy" d9b100f2f636 sammy/ubuntu-nodejs
    
    

    enable docker auto start on restart of the vm

    $ sudo systemctl enable docker

    install docker compose

    apt install docker-compose

    get a basic lamp stack running on docker with local php files

    mkdir $HOME/apache && cd $HOME/apache
    
    printf '<?php phpinfo(); ?>' > info.php
    
    docker run -d --name=apache -p 8085:80 -v $HOME/apache:/var/www/html php:apache
    
    test it.
    
    nerd2.kruxor.com:8085
    
    running but getting error
    http://nerd2.kruxor.com:8085/
    
    http://nerd2.kruxor.com:8085/info.php

    working on info.php

    stop and delete the image

    $ docker stop apache
    $ docker rm apache
    $ docker rmi php:apache

    install and run wordpress...

    this will create a wordpress and mysql containers and wordpress.

    do a test install of wordpress and sqlserver... from here:

    https://blog.ssdnodes.com/blog/getting-started-docker-vps/

    mkdir wp_test && cd wp_test
    
    nano docker-compose.yml
    
    version: '2'
    
    services:
       db:
         image: mysql:5.7
         volumes:
           - db_data:/var/lib/mysql
         restart: always
         environment:
           MYSQL_ROOT_PASSWORD: __password__
           MYSQL_DATABASE: wordpress
           MYSQL_USER: wordpress
           MYSQL_PASSWORD: __password_
         container_name: wp_test_db wordpress: depends_on: - db image: wordpress:latest ports: - "8085:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: __password_g container_name: wp_test volumes: db_data: docker-compose up -d docker ps test: http://nerd2.kruxor.com:8085 to save the data and shut down docker-compose down

    then need to figure out how to route nginx to the different docker containers, i guess just run them on diff ports like this:

    docker run -d --name=apache -p 8085:80 -v $HOME/apache:/var/www/html php:apache

    Hosting multiple SSL-enabled sites with Docker and Nginx

    In one of our most popular tutorials- Host multiple websites on one VPS with Docker and Nginx-I covered how you can use the nginx-proxy Docker container to host multiple websites or web apps on a single VPS using different containers. Link.

    nginx proxy

    mkdir nginx-proxy && cd nginx-proxy
    
    docker network create nginx-proxy
    
    36649645c730d7c433c85af48d3ad52fd16f4e16470c96ea7e6f0e5f1b7fb125
    
    

    Setup ngix reverse proxy

    Automated Nginx Reverse Proxy for Docker

    A reverse proxy server is a server that typically sits in front of other web servers in order to provide additional functionality that the web servers may not provide themselves. For example, a reverse proxy can provide SSL termination, load balancing, request routing, caching, compression or even A/B testing. Link.
     
    https://github.com/nginx-proxy/nginx-proxy

    Hosting multiple SSL-enabled sites with Docker and Nginx

    In one of our most popular tutorials- Host multiple websites on one VPS with Docker and Nginx-I covered how you can use the nginx-proxy Docker container to host multiple websites or web apps on a single VPS using different containers. Link.
     
    mkdir nginx-proxy && cd nginx-proxy
    
    docker network create nginx-proxy
    
    db02b5af510e6e53b8d170705136fa2b8db1dac5a6f4ab3e82e400404a5d95d6
    
    nano docker-compose.yml
    
    version: '3'
    
    services:
      nginx:
        image: nginx:1.13.1
        container_name: nginx-proxy
        ports:
          - "80:80"
          - "443:443"
        volumes:
          - conf:/etc/nginx/conf.d
          - vhost:/etc/nginx/vhost.d
          - html:/usr/share/nginx/html
          - certs:/etc/nginx/certs
        labels:
          - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
    
      dockergen:
        image: jwilder/docker-gen:0.7.3
        container_name: nginx-proxy-gen
        depends_on:
          - nginx
        command: -notify-sighup nginx-proxy -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
        volumes:
          - conf:/etc/nginx/conf.d
          - vhost:/etc/nginx/vhost.d
          - html:/usr/share/nginx/html
          - certs:/etc/nginx/certs
          - /var/run/docker.sock:/tmp/docker.sock:ro
          - ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
    
      letsencrypt:
        image: jrcs/letsencrypt-nginx-proxy-companion
        container_name: nginx-proxy-le
        depends_on:
          - nginx
          - dockergen
        environment:
          NGINX_PROXY_CONTAINER: nginx-proxy
          NGINX_DOCKER_GEN_CONTAINER: nginx-proxy-gen
        volumes:
          - conf:/etc/nginx/conf.d
          - vhost:/etc/nginx/vhost.d
          - html:/usr/share/nginx/html
          - certs:/etc/nginx/certs
          - /var/run/docker.sock:/var/run/docker.sock:ro
    
    volumes:
      conf:
      vhost:
      html:
      certs:
    
    # Do not forget to 'docker network create nginx-proxy' before launch, and to add '--network nginx-proxy' to proxied containers. 
    
    networks:
      default:
        external:
          name: nginx-proxy
    
    
    
    curl https://raw.githubusercontent.com/jwilder/nginx-proxy/master/nginx.tmpl > nginx.tmpl
    
    
    docker-compose up -d
    
    docker ps
    
    check logs with (optional)
    docker logs

    Get containers working with the nginx proxy

    add the following to the container settings in docker compose

    test this with a wordpress installation

    environment:
        VIRTUAL_HOST: feeds.example.com
        LETSENCRYPT_HOST: feeds.example.com
        LETSENCRYPT_EMAIL: foo@example.com
    
    environment:
        VIRTUAL_HOST: wp3.kruxor.com
        LETSENCRYPT_HOST: wp3.kruxor.com
        LETSENCRYPT_EMAIL: email_@gmail.com
    networks:
      default:
        external:
          name: nginx-proxy
    expose:
      - 80

    Install wordpress using virtual hosts and ssl

    mkdir $HOME/wp3 && cd $HOME/wp3
    
    nano docker-compose.yml
    version: "3"
    
    services:
       db_node_domain:
         image: mysql:5.7
         volumes:
            - db_data:/var/lib/mysql
         restart: always
         environment:
            MYSQL_ROOT_PASSWORD: __password__
            MYSQL_DATABASE: wordpress
            MYSQL_USER: wordpress
            MYSQL_PASSWORD: __password__
         container_name: wp_test_db
    
       wordpress:
         depends_on:
            - db_node_domain
         image: wordpress:latest
         expose:
            - 80
         restart: always
         environment:
            VIRTUAL_HOST: wp3.kruxor.com
            LETSENCRYPT_HOST: wp3.kruxor.com
            LETSENCRYPT_EMAIL: __email__@gmail.com
            WORDPRESS_DB_HOST: db_node_domain:3306
            WORDPRESS_DB_USER: wordpress
            WORDPRESS_DB_PASSWORD: __password__
         container_name: wp_test
    volumes:
      db_data:
    
    networks:
      default:
        external:
          name: nginx-proxy

    docker-compose up -d

    Custom Container for Core, PHP and SQLite, Nginx

    Get started with Docker Compose
    Estimated reading time: 11 minutes On this page you build a simple Python web application running on Docker Compose. The application uses the Flask framework and maintains a hit counter in Redis. While the sample uses Python, the concepts demonstrated here should be understandable even if you're not familiar with it. Link
    https://docs.docker.com/compose/gettingstarted/
    

    copy core files to git private and

    or just zip them up and then download with curl or wget

    leave the git part for another time

    copy kruxor.com

    tar gz something

    tar -czvf ~/backup/$1.tar.gz /var/www/html/$1/
    
    tar -czvf ~/kruxor.tar.gz /var/www/html/kruxor.com/
    
    wget https://kruxor.com/kruxor_backup_may_2022.tar.gz

    un tar gz something

    tar -xf kruxor_backup_may_2022.tar.gz

    docker compose for php fpm and nginx running core on proxy

    version: "3"
    services:
      nginx:
        build:
          context: .
          dockerfile: nginx/Dockerfile
        ports: 
          - "8080:80"
        networks:
          - internal
        volumes:
          - ./core/:/var/www/html/
          -  /logs/nginx:/var/log/nginx/
      php:
        image: php:fpm-alpine
        networks:
          - internal
        volumes:
          - ./data/:/var/www/html
    networks:
      internal:
        driver: bridge

    i dont think you need nginx as well as its already running as a proxy image

    this one should work once the virtual and lets encrypt hosts are set.

    format yaml here

    Best YAML Formatter Online: Advance YAML Formatter

    Online YAML Formatter will format yaml data, and helps to validate, convert YAML to JSON. Save and Share YAML. Link
    nano docker-compose.yml
    version: "3"
    
    services:
      nginx:
        build:
          context: .
          dockerfile: nginx/Dockerfile
        ports: 
          - "8080:80"
        volumes:
          - ./core/:/var/www/html/
          -  /logs/nginx:/var/log/nginx/
      php:
        image: php:fpm-alpine
        volumes:
          - ./core/:/var/www/html
        expose:
            - 80
        restart: always
        environment:
            VIRTUAL_HOST: nerd3.kruxor.com
            LETSENCRYPT_HOST: nerd3.kruxor.com
            LETSENCRYPT_EMAIL: email_@gmail.com
        container_name: core_kruxor
    networks:
      default:
        external:
          name: nginx-proxy
    docker-compose up -d
    test on nerd3.kruxor.com
    docker-compose down

    try php only with route via nginx proxy - this works with ssl, but gives error

    version: "3"
    
    services:
      php:
        image: php:fpm-alpine
        volumes:
          - ./core/:/var/www/html
        expose:
            - 80
        restart: always
        environment:
            VIRTUAL_HOST: nerd3.kruxor.com
            LETSENCRYPT_HOST: nerd3.kruxor.com
            LETSENCRYPT_EMAIL: __email__@gmail.com
        container_name: core_kruxor
    networks:
      default:
        external:
          name: nginx-proxy

    example config for nginx and php only

    version: "3"
    services:
      nginx:
        build:
          context: .
          dockerfile: nginx/Dockerfile
        ports: 
          - "8080:80"
        networks:
          - internal
        volumes:
          - ./data/:/var/www/html/
          -  /logs/nginx:/var/log/nginx/
      php:
        image: php:fpm-alpine
        networks:
          - internal
        volumes:
          - ./data/:/var/www/html
    networks:
      internal:
        driver: bridge
      external:
        name: nginx-proxy

    wordpress config as example

    version: "3"
    
    services:
       wordpress:
         depends_on:
            - db_node_domain
         image: wordpress:latest
         expose:
            - 80
         restart: always
         environment:
            VIRTUAL_HOST: wp3.kruxor.com
            LETSENCRYPT_HOST: wp3.kruxor.com
            LETSENCRYPT_EMAIL: __email__@gmail.com
            WORDPRESS_DB_HOST: db_node_domain:3306
            WORDPRESS_DB_USER: wordpress
            WORDPRESS_DB_PASSWORD: _password__
         container_name: wp_test
    volumes:
      db_data:
    
    networks:
      default:
        external:
          name: nginx-proxy

    copy wp profile for kruxor.com

    version: "3"
    
    services:
       db_node_domain:
         image: mysql:5.7
         volumes:
            - db_data:/var/lib/mysql
         restart: always
         environment:
            MYSQL_ROOT_PASSWORD: __password__
            MYSQL_DATABASE: wordpress
            MYSQL_USER: wordpress
            MYSQL_PASSWORD: __password__
         container_name: wp_test_db
    
       wordpress:
         depends_on:
            - db_node_domain
         image: wordpress:latest
         expose:
            - 80
         restart: always
         environment:
            VIRTUAL_HOST: wp3.kruxor.com
            LETSENCRYPT_HOST: wp3.kruxor.com
            LETSENCRYPT_EMAIL: __email__@gmail.com
            WORDPRESS_DB_HOST: db_node_domain:3306
            WORDPRESS_DB_USER: wordpress
            WORDPRESS_DB_PASSWORD: __password__
         container_name: wp_test
    volumes:
      db_data:
    
    networks:
      default:
        external:
          name: nginx-proxy

    Next try

    Dockerise your PHP application with Nginx and PHP7-FPM

    Before we start, we have to agree on one thing - Docker is super cool! If you are not familiar with Docker, I suggest to have a look at the tons of "Getting starting with Docker" or "What is Docker?" articles and then come back here.
    http://geekyplatypus.com/dockerise-your-php-application-with-nginx-and-php7-fpm/
    version: "3"
    
    services:
      php:
        image: php:fpm-alpine
        volumes:
          - ./core/:/var/www/html
        expose:
            - 80
        restart: always
        environment:
            VIRTUAL_HOST: nerd3.kruxor.com
            LETSENCRYPT_HOST: nerd3.kruxor.com
            LETSENCRYPT_EMAIL: __email__@gmail.com
        container_name: core_kruxor
    networks:
      default:
        external:
          name: nginx-proxy

    just nginx

    web:
        image: nginx:latest
        ports:
            - "8080:80"
        volumes:
            - ./core:/core
            - ./site.conf:/etc/nginx/conf.d/site.conf

    site.conf

    server {
        root /core;
        server_name php-docker.local;
        error_log  /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;
        location / {
            index index.php;
            try_files $uri $uri/ @core;
            expires max;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass php:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }
        location @core {
            rewrite ^/(.*)$ /index.php?p=$1;
        }
    }

    working???...

    502 error bad gateway

    version: "3"
    
    services:
      web:
        image: nginx:latest
        ports:
            - "8080:80"
        expose:
            - 80
        volumes:
            - ./core:/core
            - ./site.conf:/etc/nginx/conf.d/site.conf
        links:
            - php
        container_name: nginx_kruxor
      php:
        image: php:7-fpm
        expose:
            - 80
        restart: always
        volumes:
            - ./core:/core
        environment:
            VIRTUAL_HOST: nerd3.kruxor.com
            LETSENCRYPT_HOST: nerd3.kruxor.com
            LETSENCRYPT_EMAIL: __email__@gmail.com
        container_name: phpfpm_kruxor
    networks:
      default:
        external:
          name: nginx-proxy

    try server conf with no rewrite

    server {
        index index.php index.html;
        server_name php-docker.local;
        error_log  /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;
        root /core;
    
        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass php:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }
    }

    copy the wordpress one and remove mysql and replace wordpress with php

    version: "3"
    
    services:
       php:
         depends_on:
            - db_node_domain
         image: php:latest
         expose:
            - 80
         restart: always
         environment:
            VIRTUAL_HOST: nerd3.kruxor.com
            LETSENCRYPT_HOST: nerd3.kruxor.com
            LETSENCRYPT_EMAIL: __email__@gmail.com
         container_name: php_core
    volumes:
      db_data:
    
    networks:
      default:
        external:
          name: nginx-proxy

    nginx solo

    working nginx only, this works with cert

    version: "3"
    
    services:
        web:
            image: nginx:latest
            ports:
                - "8080:80"
            environment:
                VIRTUAL_HOST: nerd3.kruxor.com
                LETSENCRYPT_HOST: nerd3.kruxor.com
                LETSENCRYPT_EMAIL: __email__@gmail.com
    networks:
      default:
        external:
          name: nginx-proxy

    try the php fpm on as well

    moved the envionment to web rather than php

    version: "3"
    
    services:
      web:
        image: nginx:latest
        ports:
            - "8080:80"
        volumes:
            - ./core:/core
            - ./site.conf:/etc/nginx/conf.d/site.conf
        environment:
            VIRTUAL_HOST: nerd3.kruxor.com
            LETSENCRYPT_HOST: nerd3.kruxor.com
            LETSENCRYPT_EMAIL: __email__@gmail.com
        links:
            - php
        container_name: nginx_kruxor
      php:
        image: php:8-fpm
        expose:
            - 80
        restart: always
        volumes:
            - ./core:/core
        container_name: phpfpm_kruxor
    networks:
      default:
        external:
          name: nginx-proxy

    default.conf — site.conf

    server {
        index index.php index.html;
        server_name phpfpm.local;
        error_log  /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;
        root /core;
        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass php-fpm:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }
    }

    Dockerise web server

    Dockerize your PHP application with Nginx and PHP8-FPM - marc.it digitale Lösungen
    How do I build a small web server with Nginx and PHP8 FPM using Docker Compose? If you are not yet familiar with Docker, I recommend you take a look at the tons of "What is Docker?" and "Getting Started with Docker" articles and tutorials, and then read this post. Link
     

    PHP FPM Solo with Cert

    version: "3"
    
    services:
        web:
            image: nginx:latest
            ports:
                - "8080:80"
            environment:
                VIRTUAL_HOST: nerd3.kruxor.com
                LETSENCRYPT_HOST: nerd3.kruxor.com
                LETSENCRYPT_EMAIL: __email__@gmail.com
            volumes:
                - ./src:/var/www/html
                - ./default.conf:/etc/nginx/conf.d/default.conf
            links:
                - php-fpm
        php-fpm:
            image: php:8-fpm
            environment:
                VIRTUAL_HOST: nerd3.kruxor.com
                LETSENCRYPT_HOST: nerd3.kruxor.com
                LETSENCRYPT_EMAIL: __email__@gmail.com
            volumes:
                - ./src:/var/www/html
            links:
                - web

    try php fpm solo?

    working!!!!WER@#$%#$%@$T

    working version in ~/phpfpm via proxy with ssl

    version: "3"
    
    services:
        web:
            image: nginx:latest
            ports:
                - "8080:80"
            environment:
                VIRTUAL_HOST: nerd3.kruxor.com
                LETSENCRYPT_HOST: nerd3.kruxor.com
                LETSENCRYPT_EMAIL: __email__@gmail.com
            volumes:
                - ./src:/var/www/html
                - ./default.conf:/etc/nginx/conf.d/default.conf
            links:
                - php-fpm
        php-fpm:
            image: php:8-fpm
            environment:
                VIRTUAL_HOST: nerd3.kruxor.com
                LETSENCRYPT_HOST: nerd3.kruxor.com
                LETSENCRYPT_EMAIL: __email__@gmail.com
            volumes:
                - ./src:/var/www/html
    networks:
      default:
        external:
          name: nginx-proxy

    https://i.imgur.com/xxuO2AN.png

    default.conf

    server {
        index index.php index.html;
        server_name phpfpm.local;
        error_log  /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;
        root /var/www/html;
        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass php-fpm:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }
    }

    copy this to core and test on kruxor com

    new default.conf with rewrite

    /code

    server {
        index index.php index.html;
        server_name phpfpm.local;
        error_log  /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;
        root /var/www/html;
        location ~ \.php$ {
            #try_files $uri =404;
    				try_files $uri $uri/ @core;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass php-fpm:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }
        location @core {
            rewrite ^/(.*)$ /index.php?p=$1;
        }
    }

    new kruxor.com version for core

    version: "3"
    
    services:
        web:
            image: nginx:latest
            ports:
                - "8080:80"
            environment:
                VIRTUAL_HOST: nerd3.kruxor.com
                LETSENCRYPT_HOST: nerd3.kruxor.com
                LETSENCRYPT_EMAIL: __email__@gmail.com
            volumes:
                - ./core:/var/www/html
                - ./default.conf:/etc/nginx/conf.d/default.conf
            links:
                - php-fpm
        php-fpm:
            image: php:8-fpm
            environment:
                VIRTUAL_HOST: nerd3.kruxor.com
                LETSENCRYPT_HOST: nerd3.kruxor.com
                LETSENCRYPT_EMAIL: __email__@gmail.com
            volumes:
                - ./core:/var/www/html
    networks:
      default:
        external:
          name: nginx-proxy

    working, but the rewrite is not working in the default.conf, but otherwise its working ok.

    core conf
    
    /******************************/
    server {
        root /var/www/html/nerd3.kruxor.com;
        server_name nerd3.kruxor.com;
        location / {
            index index.php;
            try_files $uri $uri/ @core;
            expires max;
        }
        location @core {
            rewrite ^/(.*)$ /index.php?p=$1;
        }
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        }
        location ~ /\.ht {
            deny all;
        }
    }
    /******************************/

    new default.conf

    server {
        server_name phpfpm.local;
        error_log  /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;
        root /var/www/html;
        location / {
            index index.php;
            try_files $uri $uri/ @core;
            expires max;
        }
        location @core {
            rewrite ^/(.*)$ /index.php?p=$1;
        }
        location ~ \.php$ {
            #try_files $uri =404;
    				#try_files $uri $uri/ @core;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass php-fpm:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }
    }
    View Statistics
    This Week
    197
    This Month
    668
    This Year
    2395

    No Items Found.

    Add Comment
    Type in a Nick Name here
     
    Other Items in Docker
    Search Articles
    Search Articles by entering your search text above.
    Welcome

    This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

    Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

    You could also follow me on twitter or not... does anyone even use twitter anymore?

    If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

    ❤️👩‍💻🎮

    🪦 2000 - 16 Oct 2022 - Boots
    Random Quote
    For a long time it had seemed to me that life was about to begin - real life. But there was always some obstacle in the way, something to be gotten through first, some unfinished business, time still to be served, or a debt to be paid. Then life would begin. At last it dawned on me that these obstacles were my life.
    Alfred D. Souza
    Random CSS Property

    tab-size

    The tab-size CSS property is used to customize the width of tab characters (U+0009).
    tab-size css reference