How to Automatically Build and Configure Custom Docker Images with Docker file

Опубликовано: 03 Октябрь 2024
на канале: Krishna's TechInfo
72
4

In this video I have expained about How to Automatically Build and Configure Custom Docker Images with Docker file.
FROM ubuntu
MAINTAINER your_name [email protected]
RUN apt-get update
RUN apt-get install tzdata -y
RUN apt-get -y install apache2
RUN echo “Hello Apache server on Ubuntu Docker” /var/www/html/index.html
EXPOSE 80
CMD /usr/sbin/apache2ctl -D FOREGROUND


docker build -t ubuntu-apache /var/docker/ubuntu/apache/

docker images


docker run --name my-www -d -p 81:80 ubuntu-apache

docker stats my-www

vi /etc/systemd/system/apache-docker.service

[Unit]
Description=apache container
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a my-www
ExecStop=/usr/bin/docker stop -t 2 my-www

[Install]
WantedBy=local.target

systemctl daemon-reload
systemctl start apache-docker.service
systemctl status apache-docker.service