Skip to main content

Container networking

TLDR;

Opctl attaches all containers to a virtual overlay network and bridges it to the opctl host.

Adding a name attribute to container(s) makes it resolvable from other containers and the host by that name.

If multiple containers have the same name the ips of all containers will be resolved as is standard for DNS A records.

Example

  1. Run this op:

    name: containerNetworking
    run:
    parallel:
    - container:
    image: { ref: nginx }
    # some syntactically valid hostname
    name: nginx.demo.wow
    - container:
    image: { ref: alpine }
    cmd:
    - sh
    - -ce
    - |
    # wait up
    sleep 1; until ping -c1 nginx.demo.wow >/dev/null 2>&1; do :; done

    # ping forever
    ping nginx.demo.wow
  2. Observe the second container succeeds in pinging the nginx.demo.wow container.

  3. On the opctl host, open a terminal and ping nginx.demo.wow; observe successful pings to the nginx.demo.wow container.

  4. On the opctl host, open a browser and visit http://nginx.demo.wow; observe the nginx default webpage is returned.