Skip to content

Instantly share code, notes, and snippets.

@udkyo
Created April 4, 2018 18:29
Show Gist options
  • Save udkyo/67bb60565227ef5cda1b10162401a96d to your computer and use it in GitHub Desktop.
Save udkyo/67bb60565227ef5cda1b10162401a96d to your computer and use it in GitHub Desktop.
docker-compose network thing.
version: "3.4"
services:
spawner:
image: docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock
entrypoint: |
sh -c "docker run --rm --name childcontainer --network ${stack}_default -d alpine sleep 10 && ping childcontainer"
# dump it in a folder and run it with:
# stack=$(basename $PWD) docker-compose up
#
# spawner will come up, create a child container on the compose file's default network and ping it until stopped
# childcontainer evaporates after 10 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment