Tools, FAQ, Tutorials:
"docker container run --detached" - Run Container in Background
How to Create a new Container and run it in the background using the "docker container run --detach" command?
✍: FYIcenter.com
If you want to create an Alpine container and start a command that runs for a long time,
you can use the --detach option to let it run in the background.
1. Create a new container with "alpine" image and start it in the background. The container is doing nothing but sleeping for 10 hours.
fyicenter$ docker container run --name 3rd_alpine --detach alpine sleep 36000 a4570be81d299db8aa24fa1f677aa293410af0a0a436ec9cd0e162fc785dc215 fyicenter$
2. Check the container status.
fyicenter$ docker container list --latest CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES a4570be81d29 alpine "sleep 36000" 8 seconds ago Up 8 seconds 3rd_alpine
As you can see, we have started a new Alpine container that runs a long execution command in the background quietly.
You can check its log message. But it will be empty.
⇒ "docker container exec" - Execute Command on Running Container
⇐ "docker container run" - Create Container with New Command
2018-12-01, 2654🔥, 0💬
Popular Posts:
How To Pad an Array with the Same Value Multiple Times in PHP? If you want to add the same value mul...
How to troubleshoot the Orderer peer? The Docker container terminated by itself. You can follow this...
How To Get the Minimum or Maximum Value of an Array in PHP? If you want to get the minimum or maximu...
How To Change Text Fonts for Some Parts of a Paragraph? If you want to change text fonts or colors f...
Where to get a JSON.stringify() Example Code in JavaScript? Here is a good JSON.stringify() example ...