Skip to content

Instantly share code, notes, and snippets.

@agrawald
Last active May 14, 2020 07:01
Show Gist options
  • Save agrawald/9de828fa380325dfaab7063f31af0cfb to your computer and use it in GitHub Desktop.
Save agrawald/9de828fa380325dfaab7063f31af0cfb to your computer and use it in GitHub Desktop.
Spinning up sibling Docker containers from within a Docker container

Scenario

  • Node application which need redis to run functional test cases.
  • docker-compose is used to spin redis container as initial setup from within test case
  • have a docker-compose.yml file with redis service

dockerfile

FROM docker
RUN apk add --no-cache nodejs nodejs-npm docker-compose
COPY . .
RUN npm i
ENTRYPOINT npm run test

run this dockerfile

docker build . --tag app docker run -v /var/run/docker.sock:/var/run/docker.sock --name new-app -ti app

The -v flag will enable the docker container to spin sibling containers. No need for DIND.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment