mkdir dockerfiles
New-Item Dockerfile
OR
touch Dockerfile
Add following content to file
FROM ubuntu:18.04
#Install dependencies
RUN apt-get update && \
apt-get -y install apache2
# Install apache and write hello world message
RUN echo 'Hello World!' > /var/www/html/index.html
# Configure apache
RUN echo '. /etc/apache2/envvars' > /root/run_apache.sh && \
echo 'mkdir -p /var/run/apache2' >> /root/run_apache.sh && \
echo 'mkdir -p /var/lock/apache2' >> /root/run_apache.sh && \
echo '/usr/sbin/apache2 -D FOREGROUND' >> /root/run_apache.sh && \
chmod 755 /root/run_apache.sh
EXPOSE 80
CMD /root/run_apache.sh
docker build -t hello-world .
sudo docker images
docker run -t -i -p 80:80 hello-world
docker scout quickview
Push Docker Image to Docker Hub
docker login
docker tag hello-world:latest atuljkamble/hello-world
Then list images
docker images
Check image with latest tag Push image to Docker Hub
docker push atuljkamble/hello-world