sudo yum update -y
sudo amazon-linux-extras install -y docker
sudo usermod -a -G docker ec2-user
sudo service docker start
sudo systemctl enable docker
docker info
touch Dockerfile
FROM ubuntu:18.04
RUN apt-get update && \
apt-get -y install apache2
RUN echo 'Hello World!' > /var/www/html/index.html
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 .
docker image ls
docker run -d -t -i -p 80:80 hello-world
docker container ls -a
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~``
cd ..
mkdir phpimage
cd phpimage
index.php
<?php
$ip = $_SERVER['SERVER_ADDR'];
echo "IP Address is: $ip", "<br>";
?>
touch Dockerfile
FROM php:7.0-apache
COPY . /var/www/html
EXPOSE 80
~~~~~~~~~~~~~~~~~~
docker build -t php-app .
docker run -d -t -i -p 8080:80 php-app