(https://docs.docker.com/engine/install/ubuntu/)
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo usermod -aG docker $USER
sudo reboot
(?) sudo systemctl restart docker.service
docker -v
docker run hello-world
(https://laradock.io/getting-started/)
Example: Your projects located in ~/Work/projects/...
!
cd ~/Work
git clone https://github.com/laradock/laradock.git
cd laradock
cp .env.example .env
Replace {username} - your user name!
Edit .env
:
APP_CODE_PATH_CONTAINER=/home/{username}/Work
PHP_FPM_INSTALL_EXIF=true
PHP_VERSION=8.0
Files project places in dir shop
- Work/projects/shop
Open dir nginx/sites/
:
cp laravel.conf.example shop.conf
Edit shop.conf
:
...
server {
server_name shop.test;
root /home/{username}/Work/projects/shop/public;
}
...
Add the domains to the /etc/hosts
file. Add line:
127.0.0.1 adminer.test
127.0.0.1 shop.test
docker-compose down
docker-compose up -d --build workspace php-fpm adminer nginx mysql
After add new project:
docker-compose restart nginx
Other workspace:
docker-compose up -d workspace-73
docker-compose exec --user=laradock workspace-73 bash
docker-compose exec --user=laradock workspace bash
In Laravel project set .env
:
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=shop
DB_USERNAME=root
DB_PASSWORD=root
Adminer http://127.0.0.1:8081/?server=mysql&username=root
docker compose build --no-cache elasticsearch
docker compose up --force-recreate --no-deps -d elasticsearch
docker compose ps
https://laradock.io/documentation/#use-elasticsearch https://dev.to/dendihandian/elasticsearch-in-laradock-nm4
sysctl -w vm.max_map_count=262144
add to elasticsearch/Dockerfile
https://i.imgur.com/oUfr1ZC.png:
RUN elasticsearch-plugin install analysis-ukrainian
RUN elasticsearch-plugin install analysis-icu
run commands:
docker compose down elasticsearch
docker compose build --no-cache elasticsearch
docker compose up -d elasticsearch
Edit php-fpm/opcache.ini
set opcache.enable=0
docker-compose up --force-recreate --no-deps -d workspace
docker-compose build --no-cache workspace php-fpm adminer nginx mysql
docker-compose build php-fpm
docker-compose up -d --force-recreate php-fpm
docker-compose build --no-cache
docker-compose build workspace-73
docker-compose build nginx
docker-compose build php-fpm-73
docker-compose rm nginx
docker-compose up -d nginx
docker-compose up -d php-fpm-73
docker-compose up -d workspace-73
Composet AUTH - laradock/laradock#3190
WebSockets - laradock/laradock#2002
- https://i.imgur.com/LX4FWJn.png
- https://i.imgur.com/1OyHwGe.png
- https://i.imgur.com/8xnduZW.png
- https://i.imgur.com/Of3Gr7o.png
- https://i.imgur.com/O8S8wmE.png
- https://i.imgur.com/dUhbOJ2.png
NGINX Error - https://stackoverflow.com/questions/50665028/docker-error-for-nginx-cannot-start-service-nginx-driver-failed-programming-ex
Cache - docker-compose build --no-cache workspace
docker compose exec -it mysql bash
mysql
ALTER USER 'root'@'%' IDENTIFIED BY 'root';
flush privileges;
CREATE USER 'root'@'%' IDENTIFIED BY 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
flush privileges;
docker compose restart mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Fix Mysql 8.4 (SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure)
В mysql/Dockerfile
якщо є 1) то замінити на 2), якщо немає 1) - то просто вставити 2) (в кінець файлу):
1)
RUN if [ ${MYSQL_VERSION} > '8.4.0-0.000' ]; then \
echo 'mysql_native_password=on' >> /etc/mysql/conf.d/my.cnf \
else \
echo 'default-authentication-plugin=mysql_native_password' >> /etc/mysql/conf.d/my.cnf \
;fi
RUN version_gt() { \
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; \
}; \
mysql_version_trimmed=$(echo "$MYSQL_VERSION" | grep -oE '^[0-9]+\.[0-9]+'); \
if version_gt "$mysql_version_trimmed" "8.3"; then \
echo 'mysql_native_password=on' >> /etc/mysql/conf.d/my.cnf ; \
else \
echo 'default-authentication-plugin=mysql_native_password' >> /etc/mysql/conf.d/my.cnf ; \
fi
В laradock mysql/my.cnf
закоментувати (видалити) ряд: default-authentication-plugin=mysql_native_password
add next to nginx/Dockerfile
# Set upstream conf and remove the default conf
....
RUN echo "upstream php-upstream-80 { server php-fpm-80:9000; }" >> /etc/nginx/conf.d/upstream.conf
RUN echo "upstream php-upstream-70 { server php-fpm-70:9000; }" >> /etc/nginx/conf.d/upstream.conf
RUN echo "upstream php-upstream-73 { server php-fpm-73:9000; }" >> /etc/nginx/conf.d/upstream.conf
Add conf in docker-compose.yml
(for php 8.0):
workspace-80 (remove section `ports`)
...
php-fpm-80
in added conf (workspace-80, php-fpm-80) not use options:
depends_on:
- workspace
Set upstream in nginx/sites
:
server {
//...
location ~ \.php$ {
//...
fastcgi_pass php-upstream-80;
//...
}
}
Run:
docker compose build --no-cache workspace-73 php-fpm-73 nginx
docker compose restart nginx
docker compose up -d workspace-73 php-fpm-73 adminer nginx mysql
docker compose exec --user=laradock workspace-73 bash