Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

Docker-Compose:

WD=/opt/dcontainer
mkdir -p $WD/{setup,conf}
cd $WD/setup
cat << 'EOF' >docker-compose.yaml
version: '3.7'

services:
 dcontainer:
    container_name: dcontainer
    image: dcontainer
    hostname: dcontainer
    network_mode: host
    ports:
      - '6565:80'
    volumes:
      - type: bind
        source: /opt/dcontainer/conf/
        target: /etc/dcontainer

    environment:
      - 'TZ=${TZ}'

EOF
chmod +x docker-compose.yaml
cd $WD/setup
cat << 'EOF'>.env
TZ=America/Whitehorse
EOF
chmod +x .env
WD=/opt/dcontainer/setup
cat << EOF >$WD/dcontainer.service.setup.sh
cat << EOL >/lib/systemd/system/dcontainer.service
[Unit]
Description=dcontainer_Docker
Requires=docker.service network-online.target

[Service]  

WorkingDirectory=$WD
ExecStartPre=docker-compose pull
Restart=on-abnormal
ExecStart=/usr/bin/docker-compose --project-name dcontainer --project-directory $WD -f $WD/docker-compose.yaml up --force-recreate
ExecStop=/usr/bin/docker-compose --project-name dcontainer --project-directory $WD -f $WD/docker-compose.yaml stop

[Install]
WantedBy=multi-user.target
EOL
systemctl enable dcontainer
systemctl restart dcontainer
systemctl status dcontainer
EOF
chmod +x $WD/dcontainer.service.setup.sh
$WD/dcontainer.service.setup.sh
echo 'alias NAMEcli="docker exec -it NAME /bin/bash"' >> ~/.bashrc
source ~/.bashrc

Add to XYMon:

nano /etc/xymon/analysis.cfg && systemctl restart xymon xymon-client
        PROC NAME

NGinX:

##NAME
server {
       listen         80;
       server_name    sub.domain.tld;

       return         301 https://$server_name/;

}

server {
        listen 443 ssl;
        server_name sub.domain.tld;

location / {

        proxy_pass              https://localhost:8443/;
        include                 /etc/nginx/proxy.conf;
    }
}

Docker Run:

WD=/opt/container
mkdir -p $WD/{mnt,setup,...}
cd $WD/setup
cat << 'EOF' >container_docker.sh
#!/bin/bash

EOF
chmod +x container_docker.sh
./container_docker.sh
cat << 'EOF' >$WD/setup/container.service.setup.sh
cat << 'EOL' >/lib/systemd/system/container.service
[Unit]
Description=Docker_Description
Requires=docker.service network-online.target

[Service]
Restart=on-abnormal
ExecStart=/usr/bin/docker start -a container
ExecStop=/usr/bin/docker stop -t 2 container

[Install]
WantedBy=multi-user.target
EOL
systemctl enable container
systemctl restart container
systemctl status container
EOF
chmod +x $WD/setup/container.service.setup.sh
  • No labels