question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot operate services when a container is detached

See original GitHub issue

I am maintaining a Docker image that utilizes dumb-init to spawn processes. Recently I found that I cannot manage services in docker container anymore.

This works well when a container is running in foreground.

docker run --rm -uroot -it attr/drupal-lemp service nginx stop
[ ok ] Stopping nginx: nginx.

However whey I use drush run -d + drush exec it fails.

docker run --name=c1 -d attr/drupal-lemp && docker exec -uroot c1 service nginx stop
d4d38832ec1b896faa65631ba324b4bfb5335ddd0e4bfced3a8caab750c94142
Stopping nginx: nginx failed!

This might happen because the dumb-init is started by unprivileged user with sudo. I had to add sudo there because Docker does not allow to set USER after CMD.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Sep 25, 2018

You’ll want to use some sort of service manager such as runit / supervisord

0reactions
Chi-teckcommented, Sep 30, 2018

Thanks, I’will take a look at runit.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot disconnected Amazon ECS container instances ...
However, if your container agent remains in a disconnected state, then the container instance can't operate as part of your ECS cluster.
Read more >
Docker Detached Mode Explained - freeCodeCamp
Detached mode, shown by the option --detach or -d , means that a Docker container runs in the background of your terminal.
Read more >
docker container started in Detached mode stopped after ...
Run an infinite command in detached mode so the command never ends and the container never stops. I usually use "tail -f /dev/null"...
Read more >
Docker Tutorials: Detached (-d) mode in Docker - Explained
It runs the container in the background of your terminal. It does not receive input or display output.
Read more >
Cannot kill or detach a docker container using Ctrl-C or Ctrl
the container is not there (it has been terminated). If you type Control-P Control-Q instead of Control-C in the 2nd example, the container...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found