I am just a beginner in docker. I am building my own docker file using this code.
FROM alpine
RUN apk add --update redis
CMD ["redis-server"]
but the third command CMD is not running. I am unable to see successfully built message.
This is the cmd output that I am getting:
.
Please help.
3
Answers
CMD is command that runs when you create a container.
you need to run a container from that image after the build
6379 is default port for redis
Curious, I get good result,
are you up to date ? (I run on 19.03.13).
If it do not work maybe try to reinstall.
Bash output
You should run the last obtained image. Don’t expect that Dockerfile will do this for you.
Let me explain:
First let’s begin by recalling what is an image.
Image = File System Snapshot + Startup Command.
The full story recaped here :
You have got 3 instructions in your Dockerfile (FROM, RUN, CMD).
When you "docker build .", here is what happens:
Now the image B is the one that contains: a file system snapshot (with redis inside) + a startup command (redis-server).
This image (B) is now ready to be run. The result would be a container: