|
| 1 | +version: '3' |
| 2 | + |
| 3 | +services: |
| 4 | + |
| 5 | +## VOLUME CONTAINER-TO-CONTAINER AND HOST-TO-CONTAINER TEST ## |
| 6 | + |
| 7 | + volumes-example-service: |
| 8 | + image: alpine:latest |
| 9 | + container_name: volumes-example-service |
| 10 | + volumes: |
| 11 | + - /tmp:/my-volumes/host-volume |
| 12 | + - /home:/my-volumes/readonly-host-volume:ro |
| 13 | + - my-named-global-volume:/my-volumes/named-global-volume |
| 14 | + tty: true # Needed to keep the container running |
| 15 | + |
| 16 | + another-volumes-example-service: |
| 17 | + image: alpine:latest |
| 18 | + container_name: another-volumes-example-service |
| 19 | + volumes: |
| 20 | + - my-named-global-volume:/another-path/the-same-named-global-volume |
| 21 | + tty: true # Needed to keep the container running |
| 22 | + |
| 23 | +## NETWORK CONTAINER-TO-CONTAINER TEST ## |
| 24 | + |
| 25 | + network-example-service: |
| 26 | + image: karthequian/helloworld:latest |
| 27 | + container_name: network-example-service |
| 28 | + networks: |
| 29 | + - my-shared-network |
| 30 | + |
| 31 | + another-service-in-the-same-network: |
| 32 | + image: alpine:latest |
| 33 | + container_name: another-service-in-the-same-network |
| 34 | + networks: |
| 35 | + - my-shared-network |
| 36 | + |
| 37 | + tty: true # Needed to keep the container running |
| 38 | + |
| 39 | + another-service-in-its-own-network: |
| 40 | + image: alpine:latest |
| 41 | + container_name: another-service-in-its-own-network |
| 42 | + networks: |
| 43 | + - my-private-network |
| 44 | + tty: true # Needed to keep the container running |
| 45 | + |
| 46 | +## NETWORK HOST-TO-CONTAINER TEST ## |
| 47 | + |
| 48 | + network-example-service-available-to-host-on-port-1337: |
| 49 | + image: karthequian/helloworld:latest |
| 50 | + container_name: network-example-service-available-to-host-on-port-1337 |
| 51 | + networks: |
| 52 | + - my-shared-network |
| 53 | + ports: |
| 54 | + - "1337:80" |
| 55 | + |
| 56 | +volumes: |
| 57 | + my-named-global-volume: |
| 58 | + |
| 59 | +networks: |
| 60 | + my-shared-network: {} |
| 61 | + my-private-network: {} |
0 commit comments