Skip to content

Instantly share code, notes, and snippets.

@matbor
Last active August 23, 2022 06:25
Show Gist options
  • Save matbor/b7e217b7f64724c6420f441e62bb7f70 to your computer and use it in GitHub Desktop.
Save matbor/b7e217b7f64724c6420f441e62bb7f70 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Part 1
sudo yum update -y
sudo amazon-linux-extras install docker -y
sudo service docker start
sudo systemctl enable docker
sudo usermod -a -G docker ec2-user
sudo docker info
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo docker-compose version
#
# Part 2
wget https://gist.githubusercontent.com/matbor/b7e217b7f64724c6420f441e62bb7f70/raw/26e59805f2afe89fddf4460377eb115d9e3916fb/Dockerfile
sudo docker build -t hello-world .
sudo docker images --filter reference=hello-world
sudo docker run -t -d -p 80:80 hello-world
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment