039134cd96871171d2357c674d3e8e86eb7e3965
+ print them onlly in map page + wordpress plugin directory changed to save work in git
MAP
changed plugin directory in wp
inception
- change host file in virtual machine to connect to hulamy.42.fr instead of localhost
- need to put the virtual machine on sgoinfre/goinfre/user/hulamy
questions
- ? will healthcheck continue after success, every 1 secondes ?
- ? why http to https redirection doesn't works ?
docker :
-
go inside docker to debug it - docker debug image with "docker run -it"
-
docker exec -ti <container-name> bashto run bash inside a running container -
using DEBIAN_FRONTEND=noninteractive disouraged in dockerfile
-
Docker basics
- the container posess its own filesystem
- we need to copy the files it uses inside this filesystem
- we can do that with COPY
build and run a docker image
sudo docker build --tag <name> .sudo docker run <name>sudo docker imagesto list docker imagessudo docker image rm <number>sudo docker psto list docker processessudo docker ps rm <name>
execute a docker-compose file
sudo docker-compose up- or
sudo docker-compose -f ./path upto specify a path
docker pid 1
- nginx by default will create some child process (a master and some workers), then it quits (doc ?)
- when the first process of a docker container exit, the container exit (doc ?)
- so we must tell nginx to not go background : "-g 'daemon off'"
- pid1 docker problem
- official nginx docker image
- "If you add a custom CMD in the Dockerfile, be sure to include -g daemon off; in the CMD in order for nginx to stay in the foreground, so that Docker can track the process properly (otherwise your container will stop immediately after starting)!"
- SO discussion on "-g 'daemon off'"
- "When PID 1 exits, the container will exit" (where is says in the doc ?)
- "By design, containers started in detached mode exit when the root process used to run the container exits"
install and use docker and compose
-
the version installed with apt is 1.17.1, way out of date
remove old versions
sudo apt remove docker docker-engine docker.io containerd runc
preparing directory
sudo apt updatesudo apt install ca-certificates curl gnupg lsb-releasesudo mkdir -p /etc/apt/keyringscurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpgecho "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
installing docker engine
sudo apt updatesudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
check if installation worked
sudo docker run hello-world
installing docker compose (checked version on github release, see above)
- notice the 'v' below, before the version name (docker doc has it wong)
sudo curl -L "https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-composesudo chmod +x /usr/local/bin/docker-compose
run docker without sudo on linux (https://docs.docker.com/engine/install/linux-postinstall/)
sudo groupadd dockersudo usermod -aG docker $USERnewgrp docker
volumes vs bind mounts :
- docker doc: use volumes
- docker doc: use bind mounts
- comparison volume vs bind mounts
- fundamentals use of volumes and bind mounts
- how volumes and bind mounts are really differents
- bind mounts are normal files anywhere on the computer, that docker container can access with absolut path and modify. They can also be modified without docker, since they are juste files
- volumes are only modifiable by docker, they don't need an absolut path, and they are not dependent of host architecture
use password in container :
- with env variables in compose
- it's not safe to use arg to pass secret, since they are available through "docker history"
- better use docker build --secret tag
- so discussion
- engine ref secret
- compose secret
- use secret with docker
- use secret with docker SO
- four ways to use secrets
- it seems that using "secrets" only improve security for a swarm, when you must share your secrets with others, but if not the case, .env is as much secure ?
- to use secret in docker-compose, we need to use swarm, but it doesn't allow to use build, or up, so everything is different then and I don't have time to understand it fully
nginx
-
sudo nginx -twill launch a test to evaluate config file -
nginx basics
sudo netstat -tulpnto print network connections and see if nginx is running- or :
ps -ax | grep nginx sudo nginx -s quitto stop itsudo docker system prune -af --volumes->-aalso unused images,-fwithout prompt for confirmation- remove stopped containers
- remove unused networks
- remove unused images
- remove build cache
sudo docker ps -qall runnings containerssudo docker stop $(sudo docker ps -q)stop all runnings containers
openssl
mariadb
-
server vs client :
- "server" runs in the background and listen for inputs
- "client" interpret the commands to communicate with "server"
-
sudo apt install mariadb-client mariadb-server
-
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
-
ERROR 1698 (28000): Access denied for user 'root'@'localhost' 2
-
%means all entrant connections, whilelocalhostmeans only localhost connections -
can't connect to local server through socket
Can't connect to local server through socket '/run/mysqld/mysqld.sock'
sudo / find -type s
/var/lib/mysql/mysql.sock
-
mariadb basic commands :
- create user :
# mysql -u root use mysql; CREATE USER 'some_user'@'%' IDENTIFIED BY 'some_pass'; GRANT ALL PRIVILEGES ON *.* TO 'some_user'@'%' WITH GRANT OPTION; - show users :
SELECT User, Host, plugin FROM mysql.user; - delete user :
DROP USER <name>; - show databases :
SHOW DATABASES; - delete database :
DROP DATABASE <name>;
- create user :
wordpress
-
install wp
- wget https://wordpress.org/latest.tar.gz
- tar -xzvf latest.tar.gz
-
/wp-admin -
sudo /etc/hosts->127.0.0.1 hulamy.42.fr
Description
Languages
PHP
62.3%
JavaScript
28.3%
CSS
8.1%
Makefile
1.3%