Tools, FAQ, Tutorials:
Build "sleep" Image from Alpine
How to Build my "sleep" Docker image from the Alpine image? I want the container to sleep for 10 hours.
✍: FYIcenter.com
If you want to build a new Docker image that can be started with a 10-hour
sleep command, you can follow this tutorial.
1. Create a "Dockerfile" file with 2 instructions:
fyicenter$ mkdir sleep fyicenter$ cd sleep fyicenter$ vi Dockerfile FROM alpine ENTRYPOINT ["/bin/sleep","3600"]
2. Build a new image named as "sleep" using the Dockerfile in the current directory.
fyicenter$ docker build --tag sleep . Sending build context to Docker daemon 17.92kB Step 1/2 : FROM alpine ---> 055936d39205 Step 2/2 : ENTRYPOINT ["/bin/sleep","3600"] ---> Running in 6b7e3a4b320b Removing intermediate container 6b7e3a4b320b ---> 984ecb85411c Successfully built 984ecb85411c Successfully tagged sleep:latest
3. Create a new container from the image and run it in the background.
fyicenter$ docker container run --name sleep --detach sleep a66d6baf919fd65f95760a1ea182ddd283b9823cfd4bab345339cb0907f7da35
4. Check the container. It should be still running.
fyicenter$ docker container list --latest CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES e7507beb58a6 hello "/bin/sleep 3600" 8 seconds ago Up 8 seconds sleep
5. Send a command to the container to run.
fyicenter$ docker exec sleep ps -ef PID USER TIME COMMAND 1 root 0:00 /bin/sleep 3600 6 root 0:00 ps -ef
As you can see, we have created a new Docker image, with "alpine" as the based. It is configured to start a 10-hour sleep.
⇒ "python" - Python Docker Image
⇐ ENTRYPOINT [...] - Specify Entrypoint Executable
2022-06-28, 14🔥, 1💬
Popular Posts:
How to add request URL Template Parameters to my Azure API operation to make it more user friendly? ...
How to install .NET Framework in Visual Studio Community 2017? I have the Visual Studio Installer in...
How To Use an Array as a Queue in PHP? A queue is a simple data structure that manages data elements...
How To Pad an Array with the Same Value Multiple Times in PHP? If you want to add the same value mul...
What is EPUB 2.0 Metadata "dc:creator" and "dc:contributor" elements? EPUB 2.0 Metadata "dc:creator"...