CopyPastor

Detecting plagiarism made easy.

Score: 2; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Reposted on 2024-03-28
by Emil Carpenter

Original Post

Original - Posted on 2024-03-28
by Emil Carpenter



            
Present in both answers; Present only in the new answer; Present only in the old answer;

### Get IP addresses, with network names, for multiple networks, for all containers
A container might have several IP addresses in several networks. To save time by minimizing guesswork and troubleshooting, this extended answer is provided.
Tested on Ubuntu, for containers created with `docker compose`.
Output format:
==================== /container-one-name network-one-name 192.168.16.2 network-two-name 192.168.96.2 ==================== /container-two-name network-two-name 192.168.16.3 network-three-name 192.168.76.2


### Query
For *running* containers: `$(docker ps -q)`
For *all* containers (add `a`): `$(docker ps -aq)`

`docker inspect -f '{{printf "====================\n"}}{{.Name}} {{range $net,$v := .NetworkSettings.Networks}}{{printf "\n"}}{{printf "\n"}}{{printf "%s\n" $net}}{{.IPAddress}}{{printf "\n"}}{{end}}' $(docker ps -q)`
### Result, real example
==================== /local-staging-proxy 000-traefik-proxy-external 192.168.16.2 local-staging_default 192.168.96.2 local-staging_fcgi-fpm 192.168.80.2 ==================== /local-staging-web local-staging_db 192.168.64.2 local-staging_fcgi-fpm 192.168.80.3 ==================== /local-staging-db local-staging_db 192.168.64.3 ==================== /common-web-traefik 000-traefik-proxy-external 192.168.16.3 drupal-fpm-docker-base_default 192.168.32.3 ==================== /common-web-socket-proxy drupal-fpm-docker-base_default 192.168.32.2
### Get IP addresses, with network names, for multiple networks, for all containers
A container might have several IP addresses in several networks. To save time by minimizing guesswork and troubleshooting, this extended answer is provided.
Tested on Ubuntu, for containers created with `docker compose`.
Output format:
==================== /container-one-name network-one-name 192.168.16.2 network-two-name 192.168.96.2 ==================== /container-two-name network-two-name 192.168.16.3 network-three-name 192.168.76.2


### Query
For *running* containers: `$(docker ps -q)`
For *all* containers (add `a`): `$(docker ps -aq)`

`docker inspect -f '{{printf "====================\n"}}{{.Name}} {{range $net,$v := .NetworkSettings.Networks}}{{printf "\n"}}{{printf "\n"}}{{printf "%s\n" $net}}{{.IPAddress}}{{printf "\n"}}{{end}}' $(docker ps -q)`
### Result, real example
==================== /local-staging-proxy 000-traefik-proxy-external 192.168.16.2 local-staging_default 192.168.96.2 local-staging_fcgi-fpm 192.168.80.2 ==================== /local-staging-web local-staging_db 192.168.64.2 local-staging_fcgi-fpm 192.168.80.3 ==================== /local-staging-db local-staging_db 192.168.64.3 ==================== /common-web-traefik 000-traefik-proxy-external 192.168.16.3 drupal-fpm-docker-base_default 192.168.32.3 ==================== /common-web-socket-proxy drupal-fpm-docker-base_default 192.168.32.2

        
Present in both answers; Present only in the new answer; Present only in the old answer;