{"id":18749667,"url":"https://github.com/coditva/docker_private_network","last_synced_at":"2026-04-26T22:31:12.775Z","repository":{"id":98239989,"uuid":"127502724","full_name":"coditva/docker_private_network","owner":"coditva","description":"An example of a private network only accessed inside a docker container.","archived":false,"fork":false,"pushed_at":"2018-04-25T10:01:55.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-20T10:45:13.977Z","etag":null,"topics":["apache","docker","docker-machine","docker-network","docker-swarm"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coditva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-31T05:41:11.000Z","updated_at":"2023-11-18T16:53:21.000Z","dependencies_parsed_at":"2023-06-16T23:31:03.519Z","dependency_job_id":null,"html_url":"https://github.com/coditva/docker_private_network","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/coditva/docker_private_network","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coditva%2Fdocker_private_network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coditva%2Fdocker_private_network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coditva%2Fdocker_private_network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coditva%2Fdocker_private_network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coditva","download_url":"https://codeload.github.com/coditva/docker_private_network/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coditva%2Fdocker_private_network/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32315711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T21:09:39.134Z","status":"ssl_error","status_checked_at":"2026-04-26T21:09:21.240Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache","docker","docker-machine","docker-network","docker-swarm"],"created_at":"2024-11-07T17:08:18.226Z","updated_at":"2026-04-26T22:31:12.757Z","avatar_url":"https://github.com/coditva.png","language":"Shell","readme":"# Private Docker Network Example\nThis is an example of a private network on multiple machines which can only be accessed inside a docker container.\n\n## What is what\n- `server/Dockerfile` - create an Apache HTTP server on the local network.\n- `client/Dockerfile` - create clients to connect to the Apache server.\n- `server/public-html/*` - html pages to be served\n\n## How to\n\n### Create a swarm and add an overlay network\n\nOn the server machine host, initialize the cluster:\n\n    sudo docker swarm init --advertise-addr 192.168.99.101\n    # you can choose any other IP address if you like\n\nOn the remote client host, join the swarm:\n\n    sudo docker swarm join --token \u003ctoken\u003e 192.168.99.101:2377\n    # token is the one you recieved from swarm init\n    # change IP if you chose your own IP in swarm init\n\nCreate an `overlay` network for the swarm on the *server host*:\n\n    sudo docker network create --driver overlay --attachable my-network\n\n\n### Create and run server and clients:\n\n#### Use the script to do everything for you:\n\n    sudo ./execute server  # create and run server\n    sudo ./execute client  # create and run client\n    sudo ./execute clean   # remove server and client containers\n    sudo ./execute distclean  # remove docker images\n\n#### Or, execute individual commands as follows\n\nBuild the server image from the `Dockerfile` on the server host:\n\n    sudo docker build --tag \"server\" server\n\nStart the server on the `localhost`:\n\n    sudo docker run -d --name \"server\" --network my-network server\n\nBuild the client image from the `Dockerfile`:\n\n    sudo docker build --tag \"client\" client\n\nStart the client with and get tty access:\n\n    sudo docker run -it --network my-network --name client client\n    # if you're using docker-machine for VM, use option \"-d\"\n\nTest that you can connect to the server:\n\n    wget server\n\n\n## If you want to test this on a single host, use `docker-machine`:\n\nCreate two host machines. We will use `host0` for server and `host1` for client:\n\n    docker-machine create --driver virtualbox host0\n    docker-machine create --driver virtualbox host1\n\nTo execute any command in the virtual machines, use this command:\n\n    docker-machine ssh \u003cmachine_name\u003e \u003ccommand\u003e\n    # e.g. docker-machine ssh host1 \"wget server\"\n\nCopy the script, Dockerfiles and web-pages into the virtual machines:\n\n    docker-machine scp -r . host0:/home/docker\n    docker-machine scp -r client execute.sh host1:/home/docker\n\n**Follow the steps in [How to](#how-to) to create a cluster and create/run\ndocker containers.** Remember to change all commands like:\n\n    sudo docker build --tag server server\n\nTo:\n\n    docker-machine ssh host0 \"docker build --tag server server\"\n\n\n## Cleanup\n\n    sudo docker rm -f server     # remove the container\n    sudo docker rm -f client     # remove the container\n    sudo docker image rm server  # remove the image\n    sudo docker image rm client  # remove the image\n    sudo docker network rm my-network   # remove the network\n\n## License\nMIT \u0026copy; Utkarsh Maheshwari\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoditva%2Fdocker_private_network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoditva%2Fdocker_private_network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoditva%2Fdocker_private_network/lists"}