Docker Community Forums

Share and learn in the Docker community.

Shell script from host to container

First off I’m new to this kind of stuff and I’m doing it for a project for school mostly. Not a native english speaker as well so sorry for basic typo’s.

Situation
So the we will be running docker on an ubuntu 16.04 using containers based on 14.04. I am using docker-compose to start up 3 containers at a time.

Request
I would like the know if it’s possible to start a shell script on my host that will enter the container and do the requested actions.

Example
Create 3 containers, enter one then create directories inside it preparing it for use it will also run some software specific commands.

This sounds like the sort of setup you’d normally do in a Dockerfile, or else in an entrypoint script that runs when the container first starts up. Look up how docker build works. (Docker Compose can run this for you: specify build: with a directory name instead of image: "ubuntu:14.04".)

(In principle you can do what you describe with docker exec, but it’s intended more as a debugging tool and not as part of your core workflow.)