fail to create volumes

+ again changes in makefile, to be abble to erase volumes only
This commit is contained in:
hugo gogo
2022-09-18 22:43:04 +02:00
parent 9708715bb5
commit 2ffe611dd9
4 changed files with 66 additions and 33 deletions

View File

@@ -24,14 +24,16 @@ RESET = "\e[0m"
COMPOSE = ./srcs/docker-compose.yml COMPOSE = ./srcs/docker-compose.yml
HOME_D = $(shell echo $(HOME)) USER = lenovo
VOLUMES_D = /home/$(USER)/data/wp_volume \
VOLUMES_D = $(VOLUMES:%=$(HOME_D)/%) /home/$(USER)/data/db_volume
SUDO = SUDO =
# list of running containers, see : https://stackoverflow.com/questions/10024279/how-to-use-shell-commands-in-makefile # list of running containers, see : https://stackoverflow.com/questions/10024279/how-to-use-shell-commands-in-makefile
RUNNING = $(shell $(SUDO) docker ps -q) RUNNING = $(shell $(SUDO) docker ps -q)
# list of volumes
VOLUMES = $(shell $(SUDO) docker volume ls -q)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
@@ -40,7 +42,8 @@ RUNNING = $(shell $(SUDO) docker ps -q)
all: build $(VOLUMES_D) up all: build $(VOLUMES_D) up
$(VOLUMES_D): $(VOLUMES_D):
mkdir -p $(VOLUMES_D) echo volumes
# mkdir -p $(VOLUMES_D)
build: build:
$(SUDO) docker-compose -f $(COMPOSE) build $(SUDO) docker-compose -f $(COMPOSE) build
@@ -56,18 +59,23 @@ list:
@$(SUDO) docker ps -a @$(SUDO) docker ps -a
@echo $(B_YELLOW)"\nvolumes:"$(RESET) @echo $(B_YELLOW)"\nvolumes:"$(RESET)
@$(SUDO) docker volume ls @$(SUDO) docker volume ls
@echo $(B_YELLOW)"\nnetworks:"$(RESET)
@$(SUDO) docker network ls
@echo "" @echo ""
# remove project images and containers not used # remove project images and containers not used
clean: clean:
- $(SUDO) docker stop $(RUNNING) - $(SUDO) docker stop $(RUNNING)
$(SUDO) docker network prune -f
$(SUDO) docker system prune -f $(SUDO) docker system prune -f
# remove every dockers # remove everything
fclean: fclean-images: clean
- $(SUDO) docker stop $(RUNNING) - $(SUDO) docker stop $(RUNNING)
$(SUDO) docker system prune -af --volumes $(SUDO) docker system prune -af
/bin/rm -rf $(VOLUMES_D) fclean-volumes: clean
- $(SUDO) docker volume rm $(VOLUMES)
fclean: fclean-images fclean-volumes
re: fclean all re: fclean all

View File

@@ -60,10 +60,9 @@
- or `sudo docker-compose -f ./path up` to specify a path - or `sudo docker-compose -f ./path up` to specify a path
--- ---
## ressources ## docker-compose :
- [download alpine linux](https://alpinelinux.org/downloads/) - [docker compose volumes](https://docs.docker.com/compose/compose-file/#volumes)
- [dockerhub alpine image](https://hub.docker.com/_/alpine)
#### docker : #### docker :
- [docker starter guide](https://docs.docker.com/get-started/) - [docker starter guide](https://docs.docker.com/get-started/)
@@ -84,6 +83,7 @@
- [docker network](https://docs.docker.com/network/) - [docker network](https://docs.docker.com/network/)
- [depends_on](https://docs.docker.com/compose/compose-file/#depends_on) - [depends_on](https://docs.docker.com/compose/compose-file/#depends_on)
- [compose and env var](https://docs.docker.com/compose/environment-variables/) - [compose and env var](https://docs.docker.com/compose/environment-variables/)
- [specify path to named volumes](https://docs.docker.com/compose/compose-file/#volumes-top-level-element)
###### docker pid 1 ###### docker pid 1
- nginx by default will create some child process (a master and some workers), then it quits (doc ?) - nginx by default will create some child process (a master and some workers), then it quits (doc ?)
@@ -205,7 +205,6 @@
DROP DATABASE <name>; DROP DATABASE <name>;
``` ```
#### wordpress #### wordpress
- [install wp](https://wordpress.org/support/article/how-to-install-wordpress/#detailed-instructions) - [install wp](https://wordpress.org/support/article/how-to-install-wordpress/#detailed-instructions)

View File

@@ -1,4 +1,8 @@
# DOCKER-COMPOSE
LOGIN=$USER
# MARIADB SETUP # MARIADB SETUP
DB_NAME=db_wp_inception DB_NAME=db_wp_inception

View File

@@ -10,21 +10,26 @@ version: "3.8"
services: services:
# --------------------------------- # ---------------------------------
nginx: nginx:
#restart: on-failure restart: on-failure
networks:
- inception
ports: ports:
- "443:443" - "443:443"
- "80:80" - "80:80"
build: build: ./requirements/nginx
context: ./requirements/nginx
dockerfile: Dockerfile
image: nginx image: nginx
container_name: mynginx container_name: nginx_container
depends_on:
wordpress:
condition: service_started
# --------------------------------- # ---------------------------------
mariadb: mariadb:
#restart: on-failure restart: on-failure
networks:
- inception-network
env_file: .env env_file: .env
networks:
- inception
# volumes:
# - db_volume:/var/lib/mysql
build: build:
context: ./requirements/mariadb context: ./requirements/mariadb
args: args:
@@ -32,24 +37,41 @@ services:
- DB_USER=${DB_USER} - DB_USER=${DB_USER}
- DB_PSWD=${DB_PSWD} - DB_PSWD=${DB_PSWD}
image: mariadb image: mariadb
container_name: mymariadb container_name: mariadb_container
# --------------------------------- # ---------------------------------
wordpress: wordpress:
#restart: on-failure restart: on-failure
# networks:
# - inception-network
env_file: ./.env env_file: ./.env
networks:
- inception
volumes:
- type: volume
source: wp_volume
target: /var/www/html
bind:
create_host_path: true
build: ./requirements/wordpress build: ./requirements/wordpress
# context: ./requirements/wordpress
# args:
# - WP_DIR=${WP_DIR}
# depends_on:
# mariadb:
# condition: service_completed_successfully
image: wordpress image: wordpress
container_name: mywordpress container_name: wordpress_container
depends_on:
mariadb:
condition: service_started
# specify path to named volumes : https://docs.docker.com/compose/compose-file/compose-file-v3/#volume-configuration-reference
volumes:
wp_volume:
driver: local
driver_opts:
type: none
o: "bind"
device: /home/${LOGIN}/data/wp_volume
# db_volume:
# driver: local
# driver_opts:
# type: none
# o: "bind"
# mountpoint: /home/${LOGIN}/data/db_volume
networks: networks:
inception-network: inception:
driver: bridge