Skip to content

Instantly share code, notes, and snippets.

@RazinTeqB
Last active June 8, 2023 04:48
Show Gist options
  • Save RazinTeqB/0fedf67ecc32677876607fbea056f60b to your computer and use it in GitHub Desktop.
Save RazinTeqB/0fedf67ecc32677876607fbea056f60b to your computer and use it in GitHub Desktop.
#for PHP Apache MySql, PhpMyadmin
version: '3.7'
services:
php8-symfony6:
container_name: php8-symfony6
build: ./
ports:
- "9000:8000"
volumes:
- .:/var/www/html
database:
container_name: database
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: 1234
MYSQL_DATABASE: MYSQL_DATABASE
MYSQL_USER: docker_user
MYSQL_PASSWORD: 1234
ports:
- "9906:3306"
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- '8080:80'
restart: always
environment:
PMA_HOST: database
depends_on:
- database
volumes:
db-data:

Docker Some Useful Commands

2022-02-15

  • Check Docker occupied storage space

    docker system df

  • Reload system configuration

    sudo systemctl daemon-reload

  • Restart Docker

    sudo systemctl restart docker.service

  • Check Docker Status

    sudo systemctl status docker.service

  • Check Docker Ip

    sudo netstat -lntp | grep dockerd

  • Change Docker ip And port

    sudo systemctl edit docker.service

    Make Sure to reload system configuration and restart docker as mentioned above

  • Access ssh

    docker exec -t -i db /bin/bash

    docker exec -it <container-name> bash Example: docker exec -it db bash

    RUN docker ssh as root

       docker exec -it -u root <container-name> bash
    
  • To start project container

    docker-compose up -d

  • To stop project container

    docker-compose stop

    Note: Do Not use down argument as it will remove container and volume, so database data will be lost.

  • To use docker-compose.local.yml to build container

    docker-compose -f <filename> build

  • To use docker-compose.local.yml to start container

    docker-compose -f <filename> up -d


To remove docker complete data (ex: container and volume etc) and rebuild

  • Step 1 - Stop docker container (remove containers) docker-compose down

  • Step 2 - Prune docker data docker system prune -a

  • Step 3 - Prune docker images docker image prune

  • Step 4 - Prune docker volumes docker volume prune

  • Step 5 - Rebuild without using cache docker-compose build --no-cache

  • Step 6 - Start Container docker-compose up -d


FROM php:8.0.13-cli
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
locales apt-utils git libicu-dev g++ libpng-dev libxml2-dev libzip-dev libonig-dev libxslt-dev unzip libpq-dev nodejs npm wget \
apt-transport-https lsb-release ca-certificates
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen \
&& locale-gen
RUN curl -sS https://getcomposer.org/installer | php -- \
&& mv composer.phar /usr/local/bin/composer
RUN curl -sS https://get.symfony.com/cli/installer | bash \
&& mv /root/.symfony/bin/symfony /usr/local/bin
RUN docker-php-ext-configure \
intl \
&& docker-php-ext-install \
pdo pdo_mysql pdo_pgsql opcache intl zip calendar dom mbstring gd xsl
RUN pecl install apcu && docker-php-ext-enable apcu
RUN npm install --global yarn
CMD tail -f /dev/null
WORKDIR /var/www/html/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment