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

View File

@@ -60,10 +60,9 @@
- or `sudo docker-compose -f ./path up` to specify a path
---
## ressources
## docker-compose :
- [download alpine linux](https://alpinelinux.org/downloads/)
- [dockerhub alpine image](https://hub.docker.com/_/alpine)
- [docker compose volumes](https://docs.docker.com/compose/compose-file/#volumes)
#### docker :
- [docker starter guide](https://docs.docker.com/get-started/)
@@ -84,6 +83,7 @@
- [docker network](https://docs.docker.com/network/)
- [depends_on](https://docs.docker.com/compose/compose-file/#depends_on)
- [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
- nginx by default will create some child process (a master and some workers), then it quits (doc ?)
@@ -205,7 +205,6 @@
DROP DATABASE <name>;
```
#### wordpress
- [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
DB_NAME=db_wp_inception

View File

@@ -10,21 +10,26 @@ version: "3.8"
services:
# ---------------------------------
nginx:
#restart: on-failure
restart: on-failure
networks:
- inception
ports:
- "443:443"
- "80:80"
build:
context: ./requirements/nginx
dockerfile: Dockerfile
build: ./requirements/nginx
image: nginx
container_name: mynginx
container_name: nginx_container
depends_on:
wordpress:
condition: service_started
# ---------------------------------
mariadb:
#restart: on-failure
networks:
- inception-network
restart: on-failure
env_file: .env
networks:
- inception
# volumes:
# - db_volume:/var/lib/mysql
build:
context: ./requirements/mariadb
args:
@@ -32,24 +37,41 @@ services:
- DB_USER=${DB_USER}
- DB_PSWD=${DB_PSWD}
image: mariadb
container_name: mymariadb
container_name: mariadb_container
# ---------------------------------
wordpress:
#restart: on-failure
# networks:
# - inception-network
restart: on-failure
env_file: ./.env
networks:
- inception
volumes:
- type: volume
source: wp_volume
target: /var/www/html
bind:
create_host_path: true
build: ./requirements/wordpress
# context: ./requirements/wordpress
# args:
# - WP_DIR=${WP_DIR}
# depends_on:
# mariadb:
# condition: service_completed_successfully
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:
inception-network:
driver: bridge
inception: