stop and remove containers, networks, and images

docker-compose down is a command used to stop and remove containers, networks, and images created by docker-compose up.

The -v flag is short for --volumes, and it removes any anonymous volumes attached to containers.

The --rmi flag stands for “remove images”, and the all value passed to it tells docker-compose to remove all images associated with the project.

The --remove-orphans flag removes any containers that are not defined in the docker-compose.yml file.

C:\>docker-compose down -v --rmi all --remove-orphans
[+] Running 1/0
 - Image k8sc:latest  Removed  

multiline command

More on these styles:

Folded Style

Key: >
  this is my very very very
  long command</code>

Output:

this is my very very very long command\n

Mind new line-\n (end of line-EOL)

Literal Style

Key: |
  this is my very very very
  long command</code>

Output:

this is my very very very\nlong command\n

====================================================

visual studio

====================================================

visual studio code

====================================================

network

networks:
  default:
    external:
      name: bridge

====================================

docker ps --format \
"table {{.ID}}\t{{.Status}}\t{{.Names}}"
romeo@ROMEO-PC1:/mnt/c/work/thewebcafe$ docker ps --format \
> "table {{.ID}}\t{{.Status}}\t{{.Names}}"
CONTAINER ID   STATUS        NAMES
4168506b2df4   Up 8 hours    App.HttpApi.Host
9aadb140d7a5   Up 12 hours   App.DbMigrator
romeo@ROMEO-PC1:/mnt/c/work/thewebcafe$ docker ps
CONTAINER ID   IMAGE                       COMMAND               CREATED        STATUS        PORTS                                           NAMES
4168506b2df4   portal-app-hostapi:dev      "tail -f /dev/null"   8 hours ago    Up 8 hours    0.0.0.0:57607->80/tcp, 0.0.0.0:57606->443/tcp   App.HttpApi.Host
9aadb140d7a5   portal-app-dbmigrator:dev   "tail -f /dev/null"   12 hours ago   Up 12 hours   

docker inspect -f
‘{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’
4168506b2df4

docker network ls

docker network inspect -f
‘{{range .IPAM.Config}}{{.Subnet}}{{end}}’ 7c633a7e0fe9

docker network inspect -f
‘{{json .Containers}}’ 7c633a7e0fe9 |
jq ‘.[] | .Name + “:” + .IPv4Address’

romeo@ROMEO-PC1:/mnt/c/work/thewebcafe$ docker network inspect -f \
> '{{range .IPAM.Config}}{{.Subnet}}{{end}}' 7c633a7e0fe9
cker network inspect -f \
'{{json .Containers}}' 7c633a7e0fe9 | \
jq '.[] | .Name + ":" + .IPv4Address'
192.168.0.0/24

Lists the names and IPv4 addresses of all the containers attached to a Docker network by Network ID

romeo@ROMEO-PC1:/mnt/c/work/thewebcafe$ docker network inspect -f \
> '{{json .Containers}}' 7c633a7e0fe9 | \
> jq '.[] | .Name + ":" + .IPv4Address'
"App.HttpApi.Host:192.168.0.4/24"
"App.DbMigrator:192.168.0.3/24"