Snippets Collections
/* clone repo */
git clone ...

/* docker up */
docker-compose up -d

/* Install pimcore dependencies*/
docker exec -it php-fpm /bin/bash
composer install

/* Install pimcore and define local db */
docker-compose exec php-fpm vendor/bin/pimcore-install --mysql-host-socket=db --mysql-username=pimcore --mysql-password=pimcore --mysql-database=pimcore

/* change owner to ./var folder */
docker-compose exec php-fpm chown -R www-data:www-data var
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
REWRITERULE ^(.*)$ http://dockerbackend/$1 [P]
//Commmand prompt 
wsl --list -v

//Expected output
//  NAME                   STATE           VERSION
//* docker-desktop         Running         2
//  docker-desktop-data    Running         2

wsl  --shutdown

mkdir D:\Docker\wsl\data\ //your path

wsl --export docker-desktop-data "D:\Docker\wsl\data\docker-desktop-data.tar"

wsl --unregister docker-desktop-dat

awsl --import docker-desktop-data "D:\Docker\wsl\data" "D:\Docker\wsl\data\docker-desktop-data.tar" --version 2


//Delete the exported .tar file: D:\Docker\wsl\data\docker-desktop-data.tar and nothing more!
docker ps //List running containers
docker ps --all //List all containers
docker system prune //Remove unused data
docker system prune --all //Remove all unused images not just dangling ones
docker run {IMAGE} //combining 'docker create' & 'docker start'
docker run -d {IMAGE} // Run container in background and print container ID
docker run -p {systemport}:{dockerport} {IMAGE} // Map Port of the OS to the dockerport
docker run -it {IMAGE} //Input output
docker run -it {IMAGE} sh //Run docker container and shell into it
docker exec -it {IMAGE} sh //Shell into running docker container
docker build . //Build docker image with random id 
docker build -t {REPO}/{TAGNAME} . //Build docker image with random id 
docker stop {IMAGE} //Stop container from running

docker-compose up //Execute docker compose
docker-compose up --build // Rebuild Docker container and execute docker compose
docker-compose -d {IMAGE} // Run container in background and print container ID
docker-compose down //Stop container from running
kubectl rollout restart deploy -n cnext-di-demo
## Dockerfile
FROM php:7.4-fpm

# Arguments defined in docker-compose.yml
ARG user
ARG uid

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    curl \
    libpng-dev \
    libonig-dev \
    libxml2-dev \
    zip \
    unzip

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists

# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd

# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Create system user to run Composer and Artisan Commands
RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
    chown -R $user:$user /home/$user

# Set working directory
WORKDIR /var/www

USER $user

## EOF Dockerfile

## docker-compose.yaml
# Docker compose for PHP, Composer and nginx
# Check Dockerfile to create app image, PHP 7.4 and Composer
# Run: docker-compose up
# After mounted, open container cli 
# 
# Update laravel packages:
##### composer update
# Restart container to apply nginx configuration
##### docker compose restart 

version: "3.7"
services:
  app:
    build:
      args:
        user: sammy
        uid: 1000
      context: ./
      dockerfile: Dockerfile
    image: my-app
    container_name: myapp-php
    restart: always
    working_dir: /var/www/
    volumes:
      - ./:/var/www
    networks:
      - webdev

  nginx:
    image: nginx:alpine
    container_name: myapp-nginx
    restart: unless-stopped
    ports:
      - 8000:80
    volumes:
      - ./:/var/www
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
    networks:
      - webdev

networks:
  webdev:
    driver: bridge
    
## EOF docker-compose.yml

## create a nginx.conf file in the root of your app
## nginx.conf

server {
    listen 80;
    index index.php index.html;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www/public;
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app: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 / {
        try_files $uri $uri/ /index.php?$query_string;
        gzip_static on;
    }
}

## EOF nginx.conf


Run: 
docker-compose up

When container is up open container console (cli)
composer update
docker compose restart

docker build -t <image-name>
  
docker run -d -p <public-port>:<image-port> <image-name>
  
docker run -it <image-name> sh
docker ps //List running containers
docker ps --all //List all containers
docker system prune //Remove unused data
docker system prune --all //Remove all unused images not just dangling ones
docker run {IMAGE} //combining 'docker create' & 'docker start'
docker run -d {IMAGE} // Run container in background and print container ID
docker run -p {systemport}:{dockerport} {IMAGE} // Map Port of the OS to the dockerport
docker run -it {IMAGE} //Input output
docker run -it {IMAGE} sh //Run docker container and shell into it
docker exec -it {IMAGE} sh //Shell into running docker container
docker build . //Build docker image with random id 
docker build -t {REPO}/{TAGNAME}. //Build docker image with random id 
docker stop {IMAGE} //Stop container from running

docker-compose up //Execute docker compose
docker-compose up --build // Rebuild Docker container and execute docker compose
docker-compose -d {IMAGE} // Run container in background and print container ID
docker-compose down //Stop container from running
docker login -u AWS -p <password> -e none https://<aws_account_id>.dkr.ecr.<region>.amazonaws.com
docker build -t imagename -f Dockerfile2 .
# install docker
sudo apt-get install docker.io

# create and run a container from an image from the Docker Hub
sudo docker run --name firstContainer ubuntu:latest # where firstContainer is the name of the container

# list locally available docker containers
sudo docker ps -a

# open a docker container in interactive mode in the terminal
sudo docker run -it --name myContainer ubuntu:latest # where myContainer is the container name
# you can exit the container by pressing CTRL+P and CTRL+Q

# attach container to terminal
sudo docker attach myContainer # the container will now stay open in the background even after exiting via CTRL+P and CTRL+Q

# execute commands in the container running in the background
sudo docker exec myContainer echo $PATH

# delete containers
sudo docker rm -f firstContainer myContainer

# create new docker image based on your local environment/container
sudo docker commit myNginx docker_id/image_name # where myNginx is the name of your currently running container

# create new docker container from an image from a previously committed image
sudo docker run -it --name nginxNew docker_id/image_name

# list images on your machine
sudo docker image ls

# login to your docker hub account from the terminal
sudo docker login # you will be prompted to enter your id and password

# push an image to docker hub when logged into your docker account
sudo docker push docker_id/image_name

# run a docker container in the background
sudo docker run -d --name myApp nginx

# start an interactive bash terminal for the container running in the background
sudo docker exec -it myApp bashapt-get

# stop a running container
sudo docker stop myApp

# start a stopped container again
sudo docker start myApp
docker exec -it postgres psql -U postgres -d postgres -c 'SELECT * FROM "dataelement"'
-- create the databases
CREATE DATABASE IF NOT EXISTS projectone;

-- create the users for each database
CREATE USER 'projectoneuser'@'%' IDENTIFIED BY 'somepassword';
GRANT CREATE, ALTER, INDEX, LOCK TABLES, REFERENCES, UPDATE, DELETE, DROP, SELECT, INSERT ON `projectone`.* TO 'projectoneuser'@'%';

FLUSH PRIVILEGES;
rsync через docker'овский туннель гонять вот так: rsync -e 'docker exec -i' --blocking-io -rv CONTAINER_NAME:/data ., главное не забыть добавить --blocking-io.
version: '2.1'

services:
  zoo1:
    image: zookeeper:3.4.9
    hostname: zoo1
    ports:
      - "2181:2181"
    environment:
        ZOO_MY_ID: 1
        ZOO_PORT: 2181
        ZOO_SERVERS: server.1=zoo1:2888:3888
    volumes:
      - ./zk-single-kafka-single/zoo1/data:/data
      - ./zk-single-kafka-single/zoo1/datalog:/datalog

  kafka1:
    image: confluentinc/cp-kafka:5.5.0
    hostname: kafka1
    ports:
      - "9092:9092"
    environment:
      KAFKA_ADVERTISED_LISTENERS: LISTENER_DOCKER_INTERNAL://kafka1:19092,LISTENER_DOCKER_EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:9092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LISTENER_DOCKER_INTERNAL:PLAINTEXT,LISTENER_DOCKER_EXTERNAL:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: LISTENER_DOCKER_INTERNAL
      KAFKA_ZOOKEEPER_CONNECT: "zoo1:2181"
      KAFKA_BROKER_ID: 1
      KAFKA_LOG4J_LOGGERS: "kafka.controller=INFO,kafka.producer.async.DefaultEventHandler=INFO,state.change.logger=INFO"
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
    volumes:
      - ./zk-single-kafka-single/kafka1/data:/var/lib/kafka/data
    depends_on:
      - zoo1
$ docker run -d \
  --name realopinsight \
  --network host \
  --publish 4583:4583 \
  rchakode/realopinsight
star

Mon Jan 17 2022 08:34:07 GMT+0000 (UTC)

#docker #pimcore
star

Mon Dec 06 2021 20:40:02 GMT+0000 (UTC)

#docker
star

Mon Dec 06 2021 11:49:55 GMT+0000 (UTC) https://blog.codetitans.pl/post/howto-docker-over-wsl2-location/

#docker #wsl2
star

Wed Dec 01 2021 08:41:07 GMT+0000 (UTC)

#powershell #docker #pods #restart
star

Thu Oct 07 2021 12:02:59 GMT+0000 (UTC)

#docker
star

Fri Oct 01 2021 11:30:05 GMT+0000 (UTC)

#docker
star

Fri Aug 13 2021 08:16:38 GMT+0000 (UTC) https://stackoverflow.com/questions/29600369/starting-and-populating-a-postgres-container-in-docker

#docker
star

Wed Jul 07 2021 19:25:34 GMT+0000 (UTC)

#docker #aws
star

Wed Apr 28 2021 08:20:00 GMT+0000 (UTC) https://stackoverflow.com/questions/32997269/copying-a-file-in-a-dockerfile-no-such-file-or-directory

#docker
star

Sat Apr 10 2021 05:55:14 GMT+0000 (UTC)

#linux #docker
star

Fri Mar 19 2021 15:46:23 GMT+0000 (UTC)

#docker #psql
star

Wed Feb 24 2021 20:06:09 GMT+0000 (UTC) https://stackoverflow.com/questions/43322033/create-database-on-docker-compose-startup

#sql #docker
star

Sun Nov 29 2020 16:44:07 GMT+0000 (UTC) https://forums.docker.com/t/start-a-gui-application-as-root-in-a-ubuntu-container/17069

#bash #docker #ubuntu
star

Wed Oct 14 2020 17:12:11 GMT+0000 (UTC) https://habr.com/ru/post/277699/

#docker #shell
star

Wed Oct 07 2020 20:56:30 GMT+0000 (UTC) https://github.com/zircote/swagger-php

#docker #swagger #php
star

Sun Jun 21 2020 12:42:52 GMT+0000 (UTC) https://github.com/simplesteph/kafka-stack-docker-compose

#kafka #docker

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension