Run background

2 snippets across 2 stacks — Bash & Linux, Docker

Also written as run in background

SHBash & Linux

Background, Foreground & Job List

SH · Process Management
syntax
command &
bg [%job]
fg [%job]
jobs
example
python3 train_model.py &
jobs
fg %1
output
[1]+  Running    python3 train_model.py &

Note Ctrl+Z suspends a foreground job. bg resumes it in the background. fg brings a background job to the foreground. jobs lists all jobs for the current shell session. %1 refers to job number 1.

DKDocker

Detached Mode (-d)

DK · Run Options
syntax
docker run -d <image>
example
docker run -d --name web-api -p 3000:3000 myapp:1.0
output
e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3...

Note Runs the container in the background and prints the container ID. Use docker logs to see its output. Without -d, your terminal is attached and Ctrl+C stops the container.