Note
This example assumes you have Docker running in daemon mode. For more information please see Running The Examples
The most boring daemon ever written.
This example assumes you have Docker installed and with the base image already imported docker pull base
.
We will use the base image to run a simple hello world daemon that will just print hello world to standard
out every second. It will continue to do this until we stop it.
Steps:
CONTAINER_ID=$(docker run -d base /bin/sh -c "while true; do echo hello world; sleep 1; done")
We are going to run a simple hello world daemon in a new container made from the base image.
docker logs $CONTAINER_ID
Check the logs make sure it is working correctly.
docker attach $CONTAINER_ID
Attach to the container to see the results in realtime.
docker ps
Check the process list to make sure it is running.
docker stop $CONTAINER_ID
Stop the container, since we don’t need it anymore.
docker ps
Make sure it is really stopped.
Video:
See the example in action
Continue to the Building a python web app example.