I'm new to docker.I followed some instruction to install a server with docker. Will it be possible for me to write a dockerfile for that image?
I'm new to docker.I followed some instruction to install a server with docker. Will it be possible for me to write a dockerfile for that image?
Yes , Docker Image is just set of instruction which you give in some format like any other thing you do.Let's take an example of installing a chrome on your computer. So we can relate all these thing withe the dockerfile . In the Dockerfile there is three main Components which is :
1. FROM - It is always the first line in your Dockerfile which have some base image or particularly we can say some OS. So for the installing chrome you need an OS. So From basically done that thing.
2.Run - This is set of instruction which tell the docker server what thing he has to do when he get the OS ( or Base Image ) . Like in our case the instruction would be like open the browser (default) then navigate to chrome.google.com and download chrome.
3.CMD - This is the instruction which tell the docker server what would be it should done when the container start.Like in our case it would be Execute chrome.exe .
So writing a Dockerfile is equal to the being given a computer with no OS and being told to install chrome.
Yes, whatever instructions you followed to install the sever. you can write down the same instruction in docker file.
For example to run node application:
FROM node:6.9.2
RUN apt-get update && apt-get install nano -y && rm -rf /var/lib/apt/lists/*
EXPOSE 8080
COPY server.js .
CMD node server.js
For complete example : https://github.com/jinternals/docker-node