Affichage des articles dont le libellé est docker-compose. Afficher tous les articles
Affichage des articles dont le libellé est docker-compose. Afficher tous les articles

jeudi 5 mai 2022

Caddy + xcaddy within a docker container

Start Caddy within a docker container and add a plugin.

https://caddyserver.com/docs/modules/security


./docker-compose.yml

version: '3.4'
networks:
  monitor-net:
    driver: bridge
volumes:
    caddy_data: {}
services:
  caddy:
    # cf. https://github.com/caddyserver/caddy/releases
    # image: caddy:2.5.0
    build:
      context: ./caddy/ # where to look for the Dockerfile
      dockerfile: Dockerfile # actual name of the Dockerfile
      args:
        image_ref: caddy:2.5.0
    container_name: caddy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./caddy:/etc/caddy
      - caddy_data:/data
    env_file:
      ./.env
    restart: unless-stopped
    networks:
      - monitor-net
    labels:
      org.label-schema.group: "monitoring"



image_ref: caddy:2.5.0 # image reference used twice in the Dockerfile, once with ${image_ref}-builder, once directly


./caddy/Dockerfile :

ARG image_ref
FROM ${image_ref}-builder AS caddy-build
RUN xcaddy build --with github.com/greenpau/caddy-security
FROM ${image_ref}
COPY --from=caddy-build /usr/bin/caddy /usr/bin/caddy


Caddyfile must exist (content not relevant here):

./caddy/Caddyfile


command :

docker-compose  up --build caddy



jeudi 28 octobre 2021

kill processes from docker-compose "container_name"

Context : 

follwing a project-name change -> renaming the directory-name/docker-compose.yml the processes that were started by docker-compose were duplicated.

From the new project :

*  impossible to see them.

From docker ps : no process listed

From OS perspective ps aux : process present.


Test 1 : kill them all !

 Step 1 : identify them

ps aux | grep $(echo "$(grep container_name docker-compose.yml | grep -v '#' | awk '{printf("%s\\|", $2)}')grep")


Step 2 : kill -9 them all


ps aux | grep $(echo "$(grep container_name docker-compose.yml | grep -v '#' | awk '{printf("%s\\|", $2)}')grep") | awk '{print $2}' | xargs sudo kill -9


-> result : when restarting docker, they're back :-( 


Test 2 : stop docker + docker-compose start

apparently working, but I lost my container's content...