Docker Community Forums

Share and learn in the Docker community.

Docker exec - strange behaviour

docker

(Ctammes) #1

I want to check if a web container has started, so I check the status of apache:
“status=$(docker exec service apache2 status)”. For some reason, $status does not only contains the text “apache2 is running”, but also the contents (all the file names) of the PWD on the dockerhost.
When I execute “docker exec service apache2 status”, without writing it to a variable, the respons is only the result of the command.

When I execute “echo $(docker exec ls /)”, there is no extra output, it works as expected.

Any suggestions?