-1

I'm in front of one dilemma that I'd like to discuss here to open a constructive discussion.

My use case is very simple:

I need to run a bash script which execute several commands like install npm, execute aws-cli and query PostgreSQL. For this last task I use psql. Easy task I'd say however Docker slightly complicate the situation.

The problem would be solved if I would create an image where I'd install all the dependencies. However the result would be a pretty big image and I'd not go with this solution.

What about to run the script with one Docker image and then from the script (inside Docker) run something like

docker run postgres:9.6.3-alpine psql

docker run node:9.8 npm

In other words would be to run docker inside docker. What do you think?

Mazzy
  • 13,354
  • 43
  • 126
  • 207
  • You can start by reading this question: [Is it ok to run docker from inside docker?](https://stackoverflow.com/questions/27879713/is-it-ok-to-run-docker-from-inside-docker) and I would continue with concepts like: `separation-of-concerns`, `fat-vs-lean images` and this article mentions a few good points [How to Not Be the Engineer Running 3.5GB Docker Images](https://www.datawire.io/not-engineer-running-3-5gb-docker-images/) – tgogos Mar 23 '18 at 12:50
  • I've already read that article – Mazzy Mar 23 '18 at 12:51

1 Answers1

0

If you want to execute docker run inside a docker, just execute first docker run with -v /var/run/docker.sock:/var/run/docker.sock option.

With this, you can access in containers to docker images defined in host or wherever.

Alejandro Galera
  • 3,445
  • 3
  • 24
  • 42