ec2에 도커 설치 등

hyuckhoon.ko·2021년 6월 19일
0

What I learned in first year

목록 보기
82/146

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

# 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 .

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

0개의 댓글