Forrest logo
back to the docker tool

docker:tldr:c63ee

docker: Run a command in the background (detached) on a running container.
$ docker exec --detach ${container_name} ${command}
try on your machine

The command docker exec --detach ${container_name} ${command} is used to run a command inside a running Docker container in detached mode.

Here's the breakdown of the command:

  • docker exec is the Docker command used to execute a command in a running container.
  • --detach flag is used to run the command in detached mode, which means it will run in the background and won't be attached to your current terminal session.
  • ${container_name} is the name or ID of the Docker container in which you want to execute the command.
  • ${command} represents the command you want to run inside the container.

By using this command, you can execute a specific command or script within a Docker container without the need to access its shell or terminal interactively. The detached mode allows the container to keep running after the command is executed.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the docker tool