Docker compose kasutamine

Allikas: Imre kasutab arvutit
Mine navigeerimisribaleMine otsikasti

Sissejuhatus

TODO

Tööpõhimõte

TODO

Käsundamine

Isikliku võrgu jms ressurssidega konteineri tekitamine

# cat docker-compose-nginx.yml 
services:
  svc_nginx:
    image: nginx:latest
    ports:
     - "8011:80"
 
    container_name: cn_nginx
   
    networks:
      - nw_nginx
     
networks:
  nw_nginx:
    name: nw_nginx
    driver: bridge

kus

  • tundub, et uuemal ajal ei ole asjakohane compose failis kasutada rida 'version: xxx'

Kasutamiseks sobib öelda

$ docker compose -f docker-compose-nginx.yml up
[+] Running 2/2
 ✔ Network nw_nginx    Created   0.1s 
 ✔ Container cn_nginx  Created   0.1s 
Attaching to cn_nginx
dc_nginx  | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
dc_nginx  | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
dc_nginx  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
...

Ning tulemusena on moodustunud sellised ressursid

$ docker network ls
NETWORK ID     NAME                   DRIVER    SCOPE
3fe6d3988e37   bridge                 bridge    local
617b4a0d5de5   host                   host      local
d4743d12eb6a   none                   null      local
67a9effbfa9b   nw_nginx               bridge    local

ning

# docker container ls
CONTAINER ID   IMAGE             COMMAND                  CREATED          STATUS        PORTS                     NAMES
78a420d0f791   nginx:latest      "/docker-entrypoint.…"   43 minutes ago   Up 1 second   0.0.0.0:8011->80/tcp      cn_nginx

Konteineri ja võrgu kustutamiseks sobib öelda

$ docker compose -f docker-compose-nginx.yml down
[+] Running 2/2
 ✔ Container cn_nginx  Removed    0.3s 
 ✔ Network nw_nginx    Removed    0.1s

Kasulikud lisamaterjalid