How to Create Docker Container That Just Runs (forever) | Docker image

Docker Apr 5, 2022

This one is great for testing and debugging in case you're not sure which "docker-entrypoint" command you will be using in the end.

Lets's create simple Dockerfile:

# U can use whatever image
FROM alpine

RUN apk add nano


RUN ["chmod", "+x", "/"]

CMD ["sh","-c","/" ]

In the same folder lets create (or call it however you want as long as it matches CMD - command above in Dockerfile):


# Run if there is nothing to do :)
while true; do sleep 9999; done
docker build -t just_run . 

For quick test you could run one-liner like this:

docker run -d --name your-container-name just_run

Or you could put it in a docker-compose.yml ...


Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.