2

I'm creating dynamically docker containers via bash script:

while getopts ":s:d:h" opt; do
    case $opt in
        s)
            for i in $(seq $2 $END); 
                do 
                    docker run -dit --name=app_client_$i -d app:client
                    docker exec -d app_client_$i $app_start
            done
            ;;
...

The docker container starts fine, but the docker exec command caused problems. When I try (without the -d):

docker exec app_client_$i $app_start

The application inside the docker container starts fine - but I'm attached to this docker container. I want to start the app inside the docker container in the background, so I use the -d parameter:

docker exec -d app_client_$i $app_start

With that the app doesn't start inside the docker container. What I am missing?

5
  • What do you get from docker logs app_client_$i? Commented Feb 26, 2016 at 10:13
  • I've already tried that. I get nothing from the logs. If I type docker logs app_client_$1 there is no output. Commented Feb 26, 2016 at 10:15
  • The value of $app_start is a java call with the java interpreter. Commented Feb 26, 2016 at 10:15
  • Weird thing in your docker run -itd which should be either a daemon or interactive, but not both, and docker exec should not be with -d, See supervisor, runit, daemontools or s6 you want to launch several processes in a container Commented Feb 26, 2016 at 10:19
  • Okay, tried it without the -i parameter inside the run command and also tried it with the quoting variables like "app_client_$i" "$app_start". Both do not work. Commented Feb 26, 2016 at 10:26

1 Answer 1

2

Okay, got it (facepalm):

With the docker -d you're going to start the process INSIDE the container in the background. So my app was already running inside the container, but in the background.

Cheers!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.