Docker : Dockerfile का प्रयोग करें2024/06/13 |
Dockerfile का उपयोग करें और स्वचालित रूप से Docker छवियां बनाएं। |
|
[1] | उदाहरण के लिए, एक Dockerfile बनाएं जिसमें Apache2 स्थापित और प्रारंभ हो। |
root@dlp:~#
apt -y install docker-buildx
root@dlp:~#
vi Dockerfile # नया निर्माण FROM ubuntu MAINTAINER ServerWorld <admin@srv.world> RUN apt-get update RUN apt-get -y install tzdata RUN apt-get -y install apache2 RUN echo "Dockerfile Test on Apache2" > /var/www/html/index.html EXPOSE 80 CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"] # छवि बनाएं ⇒ docker build -t [image name]:[tag] . root@dlp:~# docker build -t srv.world/ubuntu-apache2:latest ./ [+] Building 5.3s (4/8) docker:default => [internal] load build definition from Dockerfile 0.1s => => transferring dockerfile: 297B 0.0s => [internal] load .dockerignore 0.1s => => transferring context: 2B 0.0s => [internal] load metadata for docker.io/library/ubuntu:latest 0.0s => [1/5] FROM docker.io/library/ubuntu 0.0s => [2/5] RUN apt-get update 5.2s ..... ..... [+] Building 29.6s (9/9) FINISHED docker:default => [internal] load build definition from Dockerfile 0.1s => => transferring dockerfile: 297B 0.0s => [internal] load .dockerignore 0.1s => => transferring context: 2B 0.0s => [internal] load metadata for docker.io/library/ubuntu:latest 0.0s => [1/5] FROM docker.io/library/ubuntu 0.0s => [2/5] RUN apt-get update 7.7s => [3/5] RUN apt-get -y install tzdata 4.7s => [4/5] RUN apt-get -y install apache2 16.3s => [5/5] RUN echo "Dockerfile Test on Apache2" > /var/www/html/index.htm 0.3s => exporting to image 0.4s => => exporting layers 0.4s => => writing image sha256:d987da01ec6c2950e15b8ba662834d235bdcab141c181 0.0s => => naming to srv.world/ubuntu-apache2:latest 0.0sroot@dlp:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/ubuntu-apache2 latest d987da01ec6c About a minute ago 225MB srv.world/ubuntu-nginx latest f3f6605bb20c 15 minutes ago 123MB ubuntu latest 17c0145030df 13 days ago 76.2MB # कंटेनर चलाएँ root@dlp:~# docker run -d -p 8081:80 srv.world/ubuntu-apache2 88c8b459e9ff03d466924c8bb03f23ac5ea27b7b638a7ba4193b2c7e281b9787root@dlp:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 88c8b459e9ff srv.world/ubuntu-apache2 "/usr/sbin/apachectl…" 14 seconds ago Up 13 seconds 0.0.0.0:8081->80/tcp, :::8081->80/tcp naughty_khayyam # पहुंच सत्यापित करें root@dlp:~# curl localhost:8081 Dockerfile Test on Apache2 |
Dockerfile का प्रारूप [INSTRUCTION Arguments] है। INSTRUCTION के लिए निम्नलिखित विवरण देखें।
|
Sponsored Link |
|