Pomoc Konwersja istniejącego kontenera do pliku compose.yml

U

Usunięty użytkownik pigers

Guest
Bash:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro red5d/docker-autocompose XXX > XXX.yml
gdzie XXX to ID/nazwa działającego dockera z docker container ls

upload_2021-3-10_22-40-58.png


upload_2021-3-10_22-42-13.png


Kod:
version: "3"
services:
  navidrome:
    cap_add:
      - AUDIT_WRITE
      - CHOWN
      - DAC_OVERRIDE
      - FOWNER
      - FSETID
      - KILL
      - MKNOD
      - NET_BIND_SERVICE
      - NET_RAW
      - SETFCAP
      - SETGID
      - SETPCAP
      - SETUID
      - SYS_CHROOT
    cap_drop:
      - AUDIT_CONTROL
      - BLOCK_SUSPEND
      - DAC_READ_SEARCH
      - IPC_LOCK
      - IPC_OWNER
      - LEASE
      - LINUX_IMMUTABLE
      - MAC_ADMIN
      - MAC_OVERRIDE
      - NET_ADMIN
      - NET_BROADCAST
      - SYSLOG
      - SYS_ADMIN
      - SYS_BOOT
      - SYS_MODULE
      - SYS_NICE
      - SYS_PACCT
      - SYS_PTRACE
      - SYS_RAWIO
      - SYS_RESOURCE
      - SYS_TIME
      - SYS_TTY_CONFIG
      - WAKE_ALARM
    container_name: navidrome
    entrypoint:
      - /app/navidrome
    environment:
      - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      - ND_MUSICFOLDER=/music
      - ND_DATAFOLDER=/data
      - ND_PORT=4533
      - GODEBUG=asyncpreemptoff=1
      - ND_TRANSCODINGCACHESIZE=512MB
      - ND_SESSIONTIMEOUT=24h
      - ND_SCANINTERVAL=1m
      - ND_BASEURL=/navidrome
      - ND_LOGLEVEL=info
    hostname: b5b098f2100e
    image: deluan/navidrome:latest
    ipc: shareable
    labels:
      maintainer: deluan@navidrome.org
    logging:
      driver: json-file
      options:
        max-file: 10
        max-size: 10m
    mac_address: 02:42:0a:00:03:03
    mem_limit: 1073741824
    memswap_limit: 2147483648
    networks:
      bridge:
        aliases:
    ports:
      - 4533:4533/tcp
    restart: unless-stopped
    ulimits:
      - Hard: 64000
        Name: nofile
        Soft: 64000
    volumes:
      - navidrome_config:/data
      - /share/CACHEDEV2_DATA/DATA2/Multimedia/MP3:/music:ro
    working_dir: /app
networks:
  bridge:
    external: true


Zrzut instalacji docker do plików YML:
Bash:
#!/usr/bin/env bash
DL=$(docker container ls --format "{{.Names}}")
array=($DL)
CDATE=$(date +"%Y%m%d")
WD="/share/_DATA/DATA2/Marek/QNAP/DOCKER/"
PA="/share/_DATA/DATA2/Marek/QNAP/DOCKER/_BACKUP_$CDATE/"
mkdir -p "$PA"
command="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro red5d/docker-autocompose"
echo "Dumping container config to YML ..."
for i in "${array[@]}"
do
    echo -e "\t $i"
    CC="$command $i > $PA$i.yml"
    eval "$CC"
done

echo "Zipping folder to save space ..."
# build archive file name
ARCH="${WD}${CDATE}_dockers_configs.tar.xz"
# do some variables validation
echo "WD = $WD"
echo "ARCH = $ARCH"
echo "CDATE = $CDATE"

#read -t 5 -p "I am going to wait for 5 seconds only ..."
# compress it ...
tar cf - "$PA" | xz -9e > "$ARCH"
# fix permissions on new archive ...
echo "Fixing permissions ..."
chown pigers:pigers "$ARCH"
# cleanup folder as we compressed it ...
rm -r "$PA"

# sent a notification

#AUTH FILE for notifications
AUTH_FILE="/exploit/scripts/pushbullet_settings.json"
#sent notification that our work in done.
notify=$(jq -r '.Notifications.DockerConfigBackup' $AUTH_FILE)
if [ $notify == "true" ];
    then
    /exploit/scripts/pushbullet_notify.sh "Docker backup completed!"
    fi

upload_2021-3-17_20-59-18.png

zostanie przerobione na definicje w plikach YML:
upload_2021-3-17_20-59-47.png
 
jest prostsza metoda:
Bash:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/red5d/docker-autocompose $(docker ps -aq) > /share/Public/containers.yml
co zapisze WSZYSTKIE kontenery w formie jednego pliku w /share/Public/containers.yml
 

Użytkownicy znaleźli tą stronę używając tych słów:

  1. navidrome qnap