Local Network and Docker Compose File
This article provides an overview of a local network (192.168.1.0/24) and Docker Compose files that start containers on an Ubuntu system, which in turn attempt to connect to a remote server using TCP.
Local Network (192.168.1.0/24)
In this example, we will be working with a local network with the IP range 192.168.1.0/24.
Docker Compose Files
To start a container on an Ubuntu system using Docker Compose, you will need a YAML file that defines the services you want to run.
Example Docker Compose File
version: '3'
services:
app:
image: ubuntu
networks:
- local
command: /bin/bash -c "while true; do try_connect; sleep 1; done"
networks:
local:
driver: bridge
try_connect:
command: nc -z remote_server_ip remote_server_port
Container App Tries to Connect to Remote Server
Once the container is running, the app inside the container will attempt to connect to the remote server using TCP.