සරලව සහ පැහැදිලිව තේරුම් ගනිමු
Docker ecosystem එකේ තියෙන වැදගත්ම concepts දෙකක් තමයි:
Docker effectively භාවිතා කරන්න නම් මේ concepts දෙක අතර තියෙන සම්බන්ධතාවය සහ වෙනස හොඳින් තේරුම් ගන්න ඕන.
මෙම article එකෙන් අපි බලන්නේ:
Docker Image එකක් කියන්නේ Docker Container එකක් run කරන්න ඕනෑම application එකක්, library එකක්, dependency එකක් සහ configuration එකක් ඇතුළත් කරන lightweight, standalone, executable package එකක්.
සරලව කියනවා නම්:
Docker Image කියන්නේ Docker container එකක් create කරන්න භාවිතා කරන template එකක් හෝ ආකෘතියක්.
Docker image එක තුළ සාමාන්යයෙන් අඩංගු වෙන්නේ:
උදාහරණ ලෙස Docker ecosystem එකේ already available images කිහිපයක් තියෙනවා:
මේ images භාවිතා කරලා containers create කරන්න පුළුවන්.
Docker images වල වැදගත් ලක්ෂණ කිහිපයක් තියෙනවා.
Docker image එකක් read-only. එක modify වෙන්නේ නැහැ. Image එකෙන් container එකක් run කරනකොට changes occur වෙන්නේ container එක තුළ.
Docker image එකක් layers කිහිපයක් එකට එකතු වෙලා build වෙනවා. Example Dockerfile එකක් බලමු.
FROM node:18
WORKDIR /app
COPY . .
RUN npm install
CMD ["node", "app.js"]
මෙහි:
මේ layers එකට එකතු වෙලා final Docker image එක build වෙනවා.
Docker image එකක් multiple containers run කරන්න reuse කරන්න පුළුවන්.
උදාහරණයක්:
docker run nginx
docker run nginx
docker run nginxe
මෙහි nginx image එකෙන් containers තුනක් run වෙනවා.
Docker Container කියන්නේ Docker image එකක් run වෙන actual running environment එක.
සරලව analogy එකක් ගත්තොත්:
Container එකක් basically isolated environment එකක්.
එහි:
තිබෙනවා.
Docker container එකක් run කරනකොට, ඒ container එකේ application එක run වෙනවා, ඒක developerගේ computer එකේ run වෙනවා, server එකේ run වෙනවා, හැම තැනම run වෙනවා.
Docker container වල වැදගත් ලක්ෂණ කිහිපයක් තියෙනවා.
Virtual Machines සමඟ compare කරද්දී Docker containers:
Container එකක් run වුනාම:
මේ නිසා applications safely run කරන්න පුළුවන්.
Docker containers run කරන්න පුළුවන්:
මේ සියල්ලේ same environment එකෙන් run වෙනවා.
Docker concepts හොඳින් තේරුම් ගන්න මේ දෙක අතර difference එක බලමු.
-----------------------------------------------------------
ලක්ෂණය Docker Image Docker Container
-----------------------------------------------------------
ස්වභාවය Template එකක් Running environment
තත්ත්වය Static Running
වෙනස් කළ හැකිද Read-only Changes possible
භාවිතය Container create කිරීම Application run කිරීම
සරලව කියනවා නම්:
Docker Image එක container එකක් build කරන්න භාවිතා කරන template එකක්. Docker Container එක image එකක් run වීමෙන් ඇතිවන environment එකක්