bash – run script only when Docker stops

I want to run a script when my Docker stops. I implement it through Trap SIGTERM. It works perfectly, but when I restart the container, the script will also run. (I think restart will stop and start). I need a way to run the script only when it stops, not when it restarts. Any proposal?

The code

cleanup() {
    echo "Before Cleaning up..." 
}

trap 'cleanup' SIGTERM

it prints the "Before Cleaning up..." when i run *docker stop docker_name* and *doker restart docker_name* too

Permissions – How do I get permissions to resize the Google Cloud file system in the CoreOS Toolbox container (nspawn / docker)?

TL; DR: To attempt resize2fs /media/root/dev/sdc inside the CoreOS Toolbox container fails, message open: Operation not permitted while opening /media/root/dev/sdc. Probability privilege problem, how do I get the privileges?


I resized a Google Cloud Compute Engine zonal persistent disk from 20 GB to 50 GB. I connected the hard drive to a running VM instance to look around. The change is not shown in the file system df -h after mounting the hard drive, but it does on the device lsblk.

As far as I know, the hard drive has a single file system with no partitions. I have based this mainly on the fact that lsblk No partitions are shown for the device, and I understand that individual file system hard drives are the convention for gcp

Now I've tried resizing the file system by following these documents from Google. However, it was not so easy, since the VMs accessible to me seem to be based on a container-optimized operating system and therefore do not come with the necessary tools or a package manager. So I have to use the CoreOS Toolbox, which, if I understand it correctly, will run a Docker container systemd-nspawn. This gives me access to a package manager and the tools I need.

Toolbox provides the root directory of the host's fs /media/rootSo I can easily access the devices. However, when I tried to use it resize2fs /media/root/dev/sdc According to the above instructions, I get the in the TL; DR mentioned error message. I tried chmod 666 the device inside the VM inside and Toolbox, and it works, but doesn't solve the problem resize2fs. I also tried running Toolbox as root, although I assumed it wouldn't do much. It was not like that. I also unmounted the hard drive before trying one of them.

One solution I imagined would be to run a VM with a more robust operating system image so that I have both "direct" access to the device and direct access to the tools. I am determined to solve the problem with the existing tools as this is more practical in production and I believe that this is possible.

Docker Bridge -> Route over a certain interface

I have two interfaces on the host. Docker is installed and br0 is forwarded via the standard interface (eth0). I added a second Docker bridge (br-alt) and I want it to be routed over the secondary connection (eth1).

How do I make sure the br-alt-Pods network is routed through eth1?

I have the following (relevant parts of the inspection) for my bridge, and the pod I have is still routing via eth0

"IPAM": {
    "Driver": "default",
    "Options": {},
    "Config": (
        {
            "Subnet": "172.16.32.0/24",
            "IPRange": "172.16.32.192/26",
            "AuxiliaryAddresses": {
                "hostint": "172.16.32.5",
                "router": "172.16.32.1"
            }
        }
    )
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
    "Network": ""
},
"Options": {
    "com.docker.network.bridge.name": "eth1"

Javascript – When trying to start the Docker container from an error: The virtual machine could not be started because a required function was not installed

Good morning people. Well, I installed the Docker on my computer. however, and I try to configure the Mongo when I try to image the following message: The virtual machine could not be started because a required feature was not installed.

NOTE: I use Windows 10 PRO. Yes, this virtualization is already activated in both the system and the BIOs, and the processor has the virtualization function.

Has anyone had this problem or knows how to solve it? Thank you and bor codar :]

ubuntu – Postgresql as Docker container that does not start with the start data of the assigned volume

On my MacBook, Postgres runs in a Docker container and I use a mapped volume to store the data. This works perfectly on site.

However, when I try to do the same on an Ubuntu server, the & # 39; initial & # 39; No data from the mapped volume. Postgres starts in an & # 39; empty & # 39; Initial state.
I can see that disk mapping is working and I have checked and confirmed the Postgres data folder in the container.
Interestingly, the mapping seems to work because an added table and data in that table are persistent in the standard Postgres database. It is also interesting to note that when trying to create a table in a new database, an error message is displayed. The new database is also persistent, but the table cannot be saved because of an error:

File "base / 16384/2611" could not be opened: No such file or directory

This is expected because the base / 16384 folder does not exist.

To me, does this seem to be a user / rights issue or a Postgres setting? I tried to run the container as root, which didn't help.

Any suggestions?

I start the container either with Docker-Compose or via the command line;

docker run --rm --name pg -e POSTGRES_PASSWORD=[password] -d -p 5432:5432 -v /ro

Docker – Nginx rewrites URLs to match the proxy address

I use a WordPress Docker container. The site can be accessed through the host computer's port 8000 when i go to localhost: 8000 boom i see my wordpress site.

It is boring to always type localhost:8000 To see my website, I decided to use nginx as a reverse proxy for my website. I set up a virtual host in Nginx that has the name proxy.site I can now visit via WordPress site http://proxy.site.

Up to this point we are fine, though http://proxy.site opens, I can see a list of my blog posts, say I want to read my latest blog post about COVID-19 when I click the link, ohohohoho it opens as http://localhost:8000/posts/covid19

I want it to open with the proxy url like in http://proxy.site/posts/covid19 I need the whole page to be accessible through it http://proxy.site Site name,

I need nginx to rewrite all of my links localhost:8000/* to proxy.site/* No body loves to enter ports when accessing a blog.

This is what my Nginx Conf file looks like

server {
        listen 80;
        listen [::]:80;

        root /var/www/proxy.site/html;
        index index.html index.htm index.nginx-debian.html;

        server_name proxy.site www.proxy.site;

        location / {
                proxy_pass http://localhost:8000;
                #proxy_set_header HOST $host;
                #proxy_redirect http://localhost:8000/ http://proxy.site/ ;
                #try_files $uri $uri/ =404;
        }
}

How can I get all URLs on the proxy site to be rewritten with my custom hostname?

 server {
        listen 80;
        listen [::]:80;

        root /var/www/proxy.site/html;
        index index.html index.htm index.nginx-debian.html;

        server_name proxy.site www.proxy.site;

        location / {
                proxy_pass http://localhost:8000;
                #proxy_set_header HOST $host;
                #proxy_redirect http://localhost:8000/ http://proxy.site/ ;
                #try_files $uri $uri/ =404;
        }
}

How can I get all URLs on the proxy site to be rewritten with my custom hostname?